object _869A extends CodeForcesApp {
  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._

  override def apply(io: IO): io.type = {
    val n = io.read[Int]
    val x, y = io.read[Vector, Int](n)
    val all = x.toSet ++ y
    var c = 0
    for {
      i <- x
      j <- y
      xor = i ^ j
      if all.contains(xor)
    } c += 1

    val ans = if (c%2 == 0) "Karen" else "Koyomi"
    io.write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)
    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
    def toSeq(implicit ev: A =:= B): Seq[A] = Seq(p._1, p._2.asInstanceOf[A])
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
    def mapValuesSafely[V2](f: V => V2): Map[K, V2] = m.mapValues(f).view.force //Hack to get around https://issues.scala-lang.org/browse/SI-4776
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}


object _869C extends CodeForcesApp {
  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._

  val arithmetic = new ModularArithmetic(998244353L) {
    override def modularInverse(n: Long): Mod = BigInt(n).modPow(mod - 2, mod).toLong
  }
  import arithmetic._

  override def apply(io: IO): io.type = {
    val a, b, c = io.read[Int]
    var ans: Mod = possibleBridges(a, b) * possibleBridges(b, c)
    ans = ans * possibleBridges(c, a)
    io.write(ans)
  }

  def possibleBridges(island1: Int, island2: Int): Mod = {
    val a = island1 min island2
    val b = island1 max island2
    (0 to a)
      .map(possibleBridges(a, b, _))
      .foldLeft(0L)({case (i, j) => toMod(i + j)})
  }

  def possibleBridges(a: Int, b: Int, k: Int): Mod = combinations(a, k) * permutations(b, k)
}

class ModularArithmetic(val mod: Long) {
  class Mod(val value: Long) {
    override val toString = value.toString
  }
  implicit def fromMod(mod: Mod): Long = mod.value
  implicit def toMod(x: Long): Mod = new Mod(x%mod)

  val factorial: IndexedSeq[Mod] = {
    val N = 5500
    val f = Array.ofDim[Mod](N)
    f(0) = 1L
    (1 until N).foreach(i => f(i) = f(i-1) * i)
    f
  }

  def modularInverse(n: Long): Mod = BigInt(n).modInverse(mod).toLong //If mod is prime override this with BigInt(n).modPow(mod - 2, mod).toLong

  def modDiv(a: Long, b: Long): Mod = a * modularInverse(b)

  def permutations(n: Int, k: Int): Mod = modDiv(factorial(n), factorial(n - k))

  def combinations(n: Int, k: Int): Mod = modDiv(permutations(n, k), factorial(k))
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)
    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
    def toSeq(implicit ev: A =:= B): Seq[A] = Seq(p._1, p._2.asInstanceOf[A])
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
    def mapValuesSafely[V2](f: V => V2): Map[K, V2] = m.mapValues(f).view.force //Hack to get around https://issues.scala-lang.org/browse/SI-4776
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}


object Main extends AlgoApp {
  type Mat = (Long, Long, Long, Long)
  def multiply(a: Mat, b: Mat, modNum: Long): Mat = {
    ((a._1 * b._1 + a._2 * b._3) % modNum,
      (a._1 * b._2 + a._2 * b._4) % modNum,
      (a._3 * b._1 + a._4 * b._3) % modNum,
      (a._3 * b._2 + a._4 * b._4) % modNum)
  }
  def power(a: Mat, b: Long, modNum: Long): Mat = {
    var tmp = a
    var ans: Mat = (1L, 0L, 0L, 1L)
    var p = b
    while (p > 0) {
      if (p % 2 == 1) {
        ans = multiply(ans, tmp, modNum)
      }
      tmp = multiply(tmp, tmp, modNum)
      p >>= 1
    }
    ans
  }

  def solve(n: Long, res: Long, modNum: Long): Long = {
    val mat = power((1L, 1L, 1L, 0L), n, modNum)
    val ans = (mat._1 + mat._2) % modNum
    if (res == 0) {
      ans
    } else {
      var (x, y, z) = (2L, n, 1L)
      while (y > 0) {
        if (y % 2 == 1)
          z = z * x % modNum
        x = x * x % modNum
        y >>= 1
      }
      (z - ans + modNum) % modNum
    }
  }

  val n = nextLong
  var k = nextLong
  val l = nextInt
  val modNum = nextLong
  var ans = 1L % modNum
  for (i <- 1 to l) {
    val tmp = solve(n, k & 1, modNum)
    ans = ans * tmp % modNum
    k >>= 1
  }
  if (k > 0) ans = 0
  println(ans)
}

abstract class AlgoApp extends App {
  import java.util.StringTokenizer

  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens())
      token = new StringTokenizer(readLine)
    token.nextToken()
  }
  def nextInt = next.toInt
  def nextLong = next.toLong
}


object Main {
  import java.io.{BufferedReader, InputStream, InputStreamReader}
  import java.util.StringTokenizer
  import scala.reflect.ClassTag

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    new Main(out, new InputReader(System.in)).solve()
    out.flush()
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null
  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){
    REP(m(0).length) { j =>
      REP(m.length) { i =>
        System.err.print(m(i)(j))
        System.err.print(" ")
      }
      System.err.println()
    }
  }
  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }
  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())
    def nextLong(): Long = java.lang.Long.parseLong(next())
    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()
    def nl(): Long = nextLong()
    def nc(): Char = nextChar()
    def ns(): String = next()
    def ns(n: Int): Array[Char] = ns().toCharArray
    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }
    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }
    def nal(n: Int): Array[Long] = map(n)(_ => nl())
    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }
  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }
  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import java.util.Arrays.sort

  import scala.collection.mutable
  import math.{abs, max, min}
  import mutable.ArrayBuffer

  // toIntとか+7とかするならvalにしろ
  @inline private def MOD = 1000000007

  def solve(): Unit = {
    val X, Y, Z = ni()

    if (abs(X - Y) > 0 && Z >= abs(X - Y) || abs(X - Y) == 0 && Z > 0) {
      out.println("?")
    } else {
      if (X > Y) {
        out.println("+")
      } else if (X < Y ) {
        out.println("-")
      } else {
        out.println(0)
      }
    }
  }
}


object Main extends App{
  val s = readLine()
  var s1, s2 = ""
  if (s.startsWith("ftp")){
    s1 = "ftp"
    s2 = s.substring(3)
  }
  else{
    s1 = "http"
    s2 = s.substring(4)
  }
  var p = s2.indexOf("ru")
  if (p == 0)
    p = 2 + s2.substring(2).indexOf("ru")
  val s3 = s2.substring(p + 2)
  s2 = s2.substring(0, p)
  if (s3.length == 0)
    println(s1 + "://" + s2 + ".ru")
  else
    println(s1 + "://" + s2 + ".ru/" + s3)
}


import scala.io.StdIn.readLine
object Triangle extends App{
  readLine
  println(if (readLine.split(' ').map(_.toInt).sorted.sliding(3).exists { case Array(x, y, z) ⇒ x + y > z }) "YES" else "NO")
}


import java.util.StringTokenizer

object _415A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val m = next.toInt
  val a = (1 to m).map(i => next.toInt)
  val ans = (0 to n).toArray

  var right = n + 1
  for (index <- a) {
    if (index < right) {
      for (i <- index until right) ans(i) = index
      right = index
    }
  }
  println((1 to n).map(i => ans(i)).mkString(" "))
}


import scala.io.StdIn

object Codeforces1099C {

  def increaseLength(postCardLine: String, lengthToIncrease: Int): String = {
    val formingLine = new StringBuilder
    var alreadyIncreased = false
    for (i <- postCardLine.indices) {
      if (postCardLine(i) == '*') {
        if (!alreadyIncreased) {
          for (_ <- 1 to lengthToIncrease) {
            formingLine.append(postCardLine(i - 1))
          }
          alreadyIncreased = true
        }
      }
      else if (postCardLine(i) != '?') {
        formingLine.append(postCardLine(i))
      }
    }

    formingLine.toString
  }

  def decreaseLength(postCardLine: String, lengthToDecrease: Int): String = {
    val formingLine = new StringBuilder
    var totalDecreased = 0
    for (i <- postCardLine.indices) {
      if (i + 1 < postCardLine.length
        && (postCardLine(i + 1) == '*' || postCardLine(i + 1) == '?')
        && totalDecreased < lengthToDecrease) {
        totalDecreased += 1
      }
      else if (postCardLine(i) != '*' && postCardLine(i) != '?') {
        formingLine.append(postCardLine(i))
      }
    }

    formingLine.toString
  }

  def convertToLength(postCardLine: String, k: Int): Option[String] = {
    val initialLength = postCardLine.count(ch => ch != '*' && ch != '?')
    val canBeIncreased = postCardLine.contains('*')
    val canBeDecreaseUpTo = postCardLine.count(ch => ch == '*' || ch == '?')

    if (initialLength < k && canBeIncreased)
      Some(increaseLength(postCardLine, k - initialLength))
    else if (initialLength >= k && canBeDecreaseUpTo >= initialLength - k)
      Some(decreaseLength(postCardLine, initialLength - k))
    else None
  }

  def main(args: Array[String]): Unit = {
    val postCardLine = StdIn.readLine().trim
    val k = StdIn.readLine().trim.toInt

    val convertedLine = convertToLength(postCardLine, k)

    println(convertedLine.getOrElse("Impossible"))
  }
}


//package codeforces.contest1097

object GennadyAndACardGame {
  def main(args: Array[String]): Unit = {
    val Array(rank, suit) = io.StdIn.readLine().split("")
    val inHand = io.StdIn.readLine.split(" ").map(s => (s(0), s(1)))

    if(inHand.exists { case (r, s) => r == rank(0) || s == suit(0) })
      println("YES")
    else
      println("NO")
  }
}


object A535 {

  import IO._
  val alpha = Array(
    "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
    "ten",  "eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen",
    "twenty")
  val tens = Array("twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    if(n <= 20) {
      println(alpha(n))
    } else {
      if(n%10 == 0) {
        println(tens(n/10 - 2))
      } else {
        println(tens(n/10 - 2) + "-" + alpha(n%10))
      }
    }
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}


import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Solution extends App {
  val arr = StdIn.readLine().split(" ").map(_.toInt)
  var a = arr(0)
  var b = arr(1)
  var x = arr(2)

  val ans = ArrayBuffer.empty[Int]
  if (a > b) {
    ans.append(0)
    a = a - 1
  }else
  {
    ans.append(1)
    b = b - 1
  }
  while(a + b > 0) {
    if (x > 1) {
      if (ans.last == 0) {
        ans.append(1)
        b = b - 1
      } else {
        ans.append(0)
        a = a - 1
      }
    }
    else
      {
        if (x == 1)
          {
            if (ans.last == 0) while(a > 0){ans.append(0);a = a - 1}
            else while(b > 0){ans.append(1);b = b - 1}
          } else
          {
            while(a > 0){ans.append(0);a = a - 1}
            while(b > 0){ans.append(1);b = b - 1}
          }

      }
       x = x - 1

  }

  println(ans.map(_.toString).reduce((a,b) => a + b))

}


object B extends App {
  val Array(x, y) = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def compare(x: Long, y: Long): Int =
    if (x == y) 0
    else {
      val n: Double = scala.math.log10(x) * y
      val d: Double = scala.math.log10(y) * x

      if (n == d) 0
      else if (n > d) 1
      else -1
    }

  val r = compare(x, y)

  if (r == 0) println("=")
  else if (r < 0) println("<")
  else println(">")
}


import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.annotation.switch
import scala.annotation.unchecked
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.collection.immutable.TreeSet
import scala.util.Random
import scala.util.control.Breaks._

object P203A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  // T minutes ... 0, 1, ...
  // a points(ini), - d_a / min
  // b points(ini), - d_b / min

  def solve(): String = {
    val X, T, A, B, Da, Db = sc.nextInt

    val points = {
      for {
        i <- 0 to T
        j <- 0 to T
      }
      yield {
        val a = if (i == T) 0
                else A - Da * i
        val b = if (j == T) 0
                else B - Db * j
        a + b
      }
    }
    points.find(_ == X) match {
      case Some(x) => "YES"
      case None    => "NO"
    }
  }

  out.println(solve)
  out.close
}


import java.util._
object GCD
{
    def gcd(a: Int,b: Int): Int = {
       if(b ==0) a else gcd(b, a%b)
    }

    def main(args: Array[String]) {
        val in = new Scanner(System.in)
        val a = in.nextInt
        val b = in.nextInt

        var res = 1
        for(i <- 1 to Math.min(a,b)){
            res *= i
        }
        print(res)
    }
}


object MikeAndPalindrome {
  def isPossibleToConvert(testString: String): Boolean = {
    if (testString.length != 0) {
      val charChangeRequired = (0 to ((testString.length - 1) / 2)).count(p => testString(p) != testString(testString.length - p - 1))
      charChangeRequired == 1 || (charChangeRequired == 0 && testString.length % 2 == 1)
    }
    else {
      false
    }
  }

  def main(args: Array[String]): Unit = {
    val input = readLine().toString
    if (isPossibleToConvert(input)) println("YES") else println("NO")
  }
}


object Main extends App {
	val Array(n, k) = scala.io.StdIn.readLine split ' ' map(_.toInt)
	println((2*n+k-1)/k+(5*n+k-1)/k+(8*n+k-1)/k)
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val data = List("vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon").filter(_.length == n)
  val str = in.next()

  println(data.find(e => e.zip(str).forall(el => el._2 == '.' || el._1 == el._2)).get)

}


import scala.collection._

object C extends App {

  def readString = Console.readLine
  def tokenizeLine = new java.util.StringTokenizer(readString)
  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }

  val Array(n, m) = readInts(2)
  val as = readInts(n)
  val bs = readInts(n)

  val maxSize = 2 * n + 1

  var paint = Array.fill(maxSize, maxSize)(Long.MaxValue / 2)
  for (i <- 0 until maxSize) paint(i)(i) = 0
  var paint0 = Array.ofDim[Long](maxSize)

  for (j <- 0 until maxSize) {
    for (step <- 0 until n) {
      val tmp = paint(j)
      paint(j) = paint0
      paint0 = tmp
      paint(j)(0) = paint0(1) + bs(step)
      paint(j)(2 * n - 1) = paint0(2 * n - 2) + as(step)
      for (i <- 1 until maxSize - 2) {
        paint(j)(i) = math.min(paint0(i + 1) + bs(step), paint0(i - 1) + as(step))
      }
    }
  }

  def mult(x: Array[Array[Long]], y: Array[Array[Long]]) = {
    val z = Array.fill(maxSize, maxSize)(0L)
    for (i <- 0 until maxSize; j <- 0 until maxSize) {
      var min = Long.MaxValue
      for (k <- 0 until maxSize) if (x(i)(k) < Long.MaxValue / 2 && y(k)(j) < Long.MaxValue / 2) min = math.min(min, x(i)(k) + y(k)(j))
      z(i)(j) = min
    }
    z
  }

  def pow(x: Array[Array[Long]], deg: Int) = {
    var res: Array[Array[Long]] = null
    var y = x
    var step = 1
    while (step <= deg) {
      if ((deg & step) > 0) res = if (res == null) y else mult(res, y)
      //if (res != null) for (p <- res) println(p.mkString(" "))
      y = mult(y, y)
      step *= 2
    }
    res
  }
  //for (p <- paint) println(p.mkString(" "))
  val full = pow(paint, m)

  println(full(0)(0))
}


object C extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val s = readLine
  val t = "abcdefghijklmnopqrstuvwxyz"
  val res = new StringBuilder

  var i, j = 0
  while (i < s.length && j < t.length) {
    if (s(i) <= t(j)) {
      res += t(j)
      i += 1
      j += 1
    } else {
      res += s(i)
      i += 1
    }
  }

  while (i < s.length) {
    res += s(i)
    i += 1
  }

  if (j == t.length) println(res.result())
  else println(-1)
}


import scala.collection.mutable
object BurningMidnightOil extends App {
  val input = io.Source.stdin.getLines.next
  val (n :: k :: Nil) = input.split(" ").map(_.toInt).toList

  val (nd, kd) = (n.toDouble, k.toDouble)
  val mini = ((nd * (1.0 - 1.0 / kd)) + 1.0).toInt
  val maxi = n

  def testV(v: Int): Boolean = {
    var acc = 0
    var next = v
    while(next != 0) {
      acc = acc + next
      next = next / k
    }
    acc >= n
  }

  def binarySearch(min: Int, max: Int, trial: Int, test: (Int => Boolean)): Int = {
    if(min == max)        trial
    else if(test(trial))  binarySearch(min, trial, (min + trial)/2, test)
    else                  binarySearch(trial + 1, max, (trial + max + 1)/2, test)
  }

  println(binarySearch(mini, maxi, (mini + maxi)/2, testV))

}


object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val Array(n, m) = lines.next().split(' ').map(_.toLong)
  def f(n: Long, el: Int) = {
    if (n % 10 >= el) 1 else 0
  }

  val result = (1 to 10).map(i => (1 to 10).filter(j => (i + j) % 5 == 0).map(j => (n / 10 + f(n, i)) * (m / 10 + f(m, j))).sum).sum
  println(result)
}


import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P047A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): String = {

    val N = sc.nextInt

    @inline
    def triangular(n: Int): Int = n * (n + 1) / 2

    @tailrec
    def loop(n: Int): String = if (N == triangular(n)) "YES"
                               else if (N < triangular(n)) "NO"
                               else loop(n + 1)

    loop(0)
  }

  out.println(solve)
  out.close
}


import java.util.Scanner

object Main{
  def log7(n: Int): String = {
    def func(b: Int, res: String): String = {
      b match{
        case 0 => res
        case x => func(b / 7, (b % 7).toString + res)
      }
    }

    val a = func(n, "")
    if(a == "") "0"
    else a
  }

  def main (args: Array[String]){
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()

    //
    val ns = log7(n-1)
    val ms = log7(m-1)

    val nl = ns.length
    val ml = ms.length

    if(nl + ml > 7){
      println(0)
    }
    else{
      val dp = new Array[Boolean](6543211)
      var ans = 0

      for(s <- "0123456".permutations){
        val nows = s.substring(0, nl+ml)
        if(!dp(nows.toInt)){
          dp(nows.toInt) = true
          val a = nows.substring(0, nl).toInt
          val b = nows.substring(nl, nl+ml).toInt
          if(a <= ns.toInt && b <= ms.toInt)
            ans += 1
        }
      }
      println(ans)
    }
  }
}


object B {
    def main(args: Array[String]) = {
        val a = readInt;
        val a_str = a toString;
        val ac2 = math.ceil(math.sqrt(a)) toInt;
        val af2 = math.floor(math.sqrt(a)) toInt;

        def good(x: Int): Boolean = x.toString exists {a_str contains _};

        val appropriateSmall = for (x <- (1 to af2)
            if a % x == 0 && good(x)) yield x;
        val appropriateBig = for (x <- (1 to (ac2 - 1))
            if a % x == 0 && good(a / x)) yield a / x;

        println((appropriateSmall length) + (appropriateBig length))
    }
}


object Main extends App {
  val in = readLine
  println(in.split("WUB").filter(_.nonEmpty).mkString(" "))
}


import java.util.Scanner

/**
 * Created by hama_du on 2014/07/19.
 */
object ProblemB extends App {
  val in = new Scanner(System.in)
  val s = in.nextLine().toCharArray
  val t = in.nextLine().toCharArray

  val solve = canSolve(s, t)
  val automaton = canAutomaton(s, t)
  val array = canArray(s, t)

  if (automaton) {
    println("automaton")
  } else if (array) {
    println("array")
  } else if (solve) {
    println("both")
  } else {
    println("need tree")
  }

  def canSolve(s: Array[Char], t: Array[Char]) = {
    countFrequency(s).zip(countFrequency(t)).filter(p => (p._1 < p._2)).size == 0
  }

  def canAutomaton(s: Array[Char], t: Array[Char]): Boolean = {
    var t_idx = 0
    var s_idx = 0
    while (t_idx < t.length) {
      while (s_idx < s.length && s(s_idx) != t(t_idx)) {
        s_idx += 1
      }
      if (s_idx < s.length) {
        s_idx += 1
        t_idx += 1
      } else {
        return false;
      }
    }
    true
  }

  def canArray(s: Array[Char], t: Array[Char]) = {
    countFrequency(s).zip(countFrequency(t)).filter(p => (p._1 == p._2)).size == 26
  }

  def countFrequency(s: Array[Char]) = {
    val cnt = Array.ofDim[Int](26)
    s.foreach(c => {
      cnt(c - 'a') += 1
    })
    cnt
  }
}


object Candies306A  extends App {
    import java.io.{InputStream, PrintStream}
    import java.util.Scanner
    solve(System.in,System.out)
    def solve(in: InputStream, out: PrintStream): Unit = {
        val scanner = new Scanner(in)
      val n = scanner.nextInt()
      val m = scanner.nextInt()
      val minK = n/m
      val b = n-minK*m
      val a = m - b
      val result = Seq((a,minK),(b,minK+1)).flatMap{case (people,numCandies) => (1 to people).map{_ => numCandies}}.mkString(" ")
      out.println(result)
    }
}


import java.util.StringTokenizer

import scala.collection.mutable

object A extends App {
  val INF = 1 << 30

  var st: StringTokenizer = _
  def read() = { st = new StringTokenizer(readLine()) }
  def int() = st.nextToken().toInt
  def long() = st.nextToken().toLong

  var q = INF

  read()
  val a = int()
  q = Math.min(q, a)
  read()
  val b = int()
  q = Math.min(q, b / 2)
  read()
  val c = int()
  q = Math.min(q, c / 4)

  println(7 * q)

}


import java.util.Scanner
import scala.language.implicitConversions

object evenodd {
  class Lazy[A](x: => A) {
    lazy val value = x
    override def toString(): String = value.toString()
  }
  object Lazy {
    def apply[A](x: => A) = new Lazy(x)
    implicit def fromLazy[A](z: Lazy[A]): A = z.value
    implicit def toLazy[A](x: => A): Lazy[A] = Lazy(x)
  }
  def memoize[I, O](f: I => O): I => O = new collection.mutable.HashMap[I, O]() {
    override def apply(key: I) = getOrElseUpdate(key, f(key))
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val N = sc.nextInt();

    if (N % 2 == 0) println("Mahmoud");
    else println("Ehab");
  }
}


import scala.io.StdIn._

object Solution {
  def main(args: Array[String]): Unit = {
    val Array(n, m) = readLine.split(" ").map(_.toInt)
    val list = readLine.toList.dropWhile(c => c != 'G' && c != 'T').reverse.dropWhile(c => c != 'G' && c != 'T').grouped(m).toList
    if ("GT".contains(list.head.head) && "GT".contains(list.last.head) && list.size > 1 && list.forall(seq => seq.head != '#')) {
      println("YES")
    } else {
      println("NO")
    }
  }
}


object CF0058A extends App {

  val str = readLine()

  if (str.matches(".*h{1,}.*e{1,}.*l{1,}.*l{1,}.*o{1,}.*")) {
    println("YES")
  } else {
    println("NO")
  }

}


object Main {
  def main(args: Array[String]) {
    val s = readLine
    if (s.count(_.isLower) >= (s.size + 1) / 2) println(s.toLowerCase)
    else println(s.toUpperCase)
  }
}


object Try1 {
  def main(args: Array[String]) {
    var n, i, m: Int = 0
    n = readInt()
    val line = Console.readLine()
    for (i <- 1 to n - 1) {
      if (line {
        i
      } != line {
        i - 1
      })
        m += 1
    }
    m %= 2
    if (line {
      0
    } == 'S' && m == 1)
      println("YES")
    else println("NO")
  }
}


object Main{
  def main(args: Array[String]) {
    val n = readInt()
    val a = readLine().split(" ").map(_.toInt)

    var c = new Array[Int](101)

    for(x <- a){
      c(x) += 1
    }

    println(c.max)
  }
}


import scala.collection.mutable._
import scala.math._
import scala.util.control.Breaks.break
import scala.util.control.Breaks.breakable
import java.util._
object Main extends App {
  val sc = new Scanner(System.in)
  val s = readLine
  val t = readLine
  val n = max(abs(s(0)-t(0)), abs(s(1)-t(1)))
  val dx = Array[Int](0,1,1,1,0,-1,-1,-1)
  val dy = Array[Int](1,1,0,-1,-1,-1,0,1)
  val d = Array[String]("U", "RU", "R", "RD", "D", "LD", "L", "LU")
  def go(s: String, t: String) {
    if(s == t) return
    val xx = (t(0)-s(0)) / (if(t(0)-s(0)!=0) abs(t(0)-s(0)) else 1)
    val yy = (t(1)-s(1)) / (if(t(1)-s(1)!=0) abs(t(1)-s(1)) else 1)
    val ss = (s(0) + xx).toChar +""+ (s(1) + yy).toChar
    for(i <- 0 until 8) {
      if(dx(i) == xx && dy(i) == yy) {
        println(d(i))
        go(ss, t)
      }
    }
  }
  println(n)
  go(s,t)
}


object B extends App {
  val n = scala.io.StdIn.readInt()

  var t = 0
  for (a <- 1 to n)
    for (b <- a to n) {
      val c = a ^ b
      if (c >= b && c <= n && a + b > c && a + c > b && c + b > a) t = t + 1
    }

  println(t)
}


import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object DreamoonStairs {

   def readInts() : Array[Int] =
     readLine.split(' ').map(_.toInt)

   def readLongs() : Array[Long] =
      readLine.split(' ').map(_.toLong)

   def readTuple() : (Int,Int) = {
     val line = readInts
     (line(0),line(1))
   }
   def readTupleLong() : (Long,Long) = {
     val line = readLongs
     (line(0),line(1))
   }

   def readTriple() : (Int,Int,Int) = {
     val line = readInts
     (line(0),line(1),line(2))
   }
   def readQuad() : (Int,Int,Int,Int) = {
     val line = readInts
     (line(0),line(1),line(2),line(3))
   }

   def solve(twos: Int, ones: Int, m: Int) : Int = {
     if (twos < 0) -1
     else {
       if ((twos+ones)%m == 0) twos + ones
       else solve(twos-1,ones+2,m)
     }
   }

   def main(args: Array[String]) {
     val (n,m) = readTuple
     println(solve(n/2, if (n%2==0) 0 else 1,m))
   }

}


import java.io._
import java.util.ArrayList
import java.util.StringTokenizer

object B_328s {

  def main(args: Array[String]): Unit = {
    var debugV = false
    def db(x: => String) = if (debugV)  println(x) // nullary function

    val is = System.in

    //COMMENT ME !
//    val is = new ByteArrayInputStream(sa1.trim.getBytes("ISO-8859-1"))
//    debugV = true

    val bis = new BufferedInputStream(is);
    val br = new BufferedReader(new InputStreamReader(bis));

    //---------------------------- parameters reading ------------------------------------
    val line1 = new StringTokenizer(br.readLine())
    val n = line1.nextToken().toInt

    //---------------------------- parameters reading end --------------------------------

    var res = 1l
    var counter = 1l
    if (n == 3) {
    } else {
      while (counter <= n) {
        if (counter == 1 || counter == 2 || counter == 3) {
          res += n-3
        } else {
          res += n-4
        }
        counter += 1
      }
    }

    println(res)

  }

}


// codeforces problem 55 B Sma

object SmallNums extends App {

  def readNums(): List[Long] = {
    val line = Console.readLine()
    val ss = line.split(" ")
    val ls: List[String] = ss toList;
    ls map (s => s.toLong)
  }

  def str2op(s: String): Op = s match {
    case "+" => new Add
    case "*" => new Mul
    case _ => throw new Error("Illegal operation " + s)
  }

  def readOps(): List[Op] = {
    val ss = Console.readLine().split(" ")
    val ls: List[String] = ss toList;
    ls map str2op
  }

  def allPairs(n: Int): List[(Int, Int)] = {
    val sq = for {
      i <- Range(1, n)
      j <- Range(0, i)
    } yield (j, i)
    sq toList
  }

  def removeA[T](l: List[T], a: Int): List[T] =
    (l take a) ::: (l drop (a + 1))

  def removeAB[T](l: List[T], a: Int, b: Int): List[T] =
    removeA(removeA(l, a), (b - 1))

  def minNum(nms: List[Long], ops: List[Op], pairs: List[(Int, Int)], mmin: Long): Long = pairs match {
    case Nil => mmin
    case (a, b) :: tl => {
      val r = ops.head.apply(nms(a), nms(b))
      val n1 = (nms length) - 1
      if (n1 == 1) {
        r
      } else {
        val mn = minNum(r :: removeAB(nms, a, b), ops.tail, allPairs(n1), Long.MaxValue)
        val min1 = if (mn < mmin) mn else mmin
        minNum(nms, ops, tl, min1)
      }
    }
  }

  val nums = readNums()
  val ops = readOps
  val n = 4
  val minv = minNum(nums, ops, allPairs(n), Long.MaxValue)
  Console.println(minv)
}

abstract class Op {
  def apply(a: Long, b: Long): Long
}
case class Add extends Op {
  def apply(a: Long, b: Long) = a + b
}
case class Mul extends Op {
  def apply(a: Long, b: Long) = a * b
}


import java.io._
import java.util.StringTokenizer

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  def solve: Int = {
    val n = nextInt
    val t = nextInt
    if (t == 10) {
      if (n == 1) {
        out.println(-1)
      } else {
        for (i <- 0 until n - 1) {
          out.print(1)
        }
        out.println(0)
      }
    } else {
      for (i <- 0 until n) {
        out.print(t)
      }
    }
    return 0
  }
}


object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer
  import java.util.Arrays

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    var ans = 0L
    REP(N - 2) { i =>
      ans += (i + 2) * (i + 3)
    }
    out.println(ans)
  }

  private val oj = System.getenv("ATCODER_DEBUG") == null

  def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }

  def debug(as: Array[Boolean]): Unit = DEBUG {
    debug(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = DEBUG {
    debug(as.mkString(" "))
  }

  def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }

  def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }
  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from) { i =>
      f(i)
    }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


import scala.io.StdIn
import scala.math.pow

object Main {
  def main(args: Array[String]): Unit = {
    println(rec(readLong, 1000000000, 9))
  }

  @annotation.tailrec
  final def rec(n: Long, x: Long, power: Int, sum: Int = 0): Int = {
    if(power == -1) return sum

    var newSum = sum
    var newN = n

    if(n == x) newSum += 1
    if(n > x) {
      newN -= x
      newSum += pow(2, power).toInt
    }

    rec(newN, x / 10, power - 1, newSum)
  }
}


import java.util.Scanner

object Main{
  def main (args: Array[String]){
    val sc = new Scanner(System.in)
    val n = sc.nextInt()

    var a = n / 2

    if (a % 2 == 0)
      a -= 1

    if (n % 2 == 1)
      println(0)
    else println(a / 2)
  }
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(d, sumTime) = in.next().split(" ").map(_.toInt)
  val data = (1 to d).map(_ => in.next().split(" ").map(_.toInt))
  val min = data.map(_.head)
  val max = data.map(_.last)
  var leftTime = sumTime - min.sum
  if (sumTime < min.sum || sumTime > max.sum)
    println("NO")
  else {
    val r = data.map{ t =>
      val q = t.head + Math.min(leftTime, t.last - t.head)
      leftTime += t.head - q
      q
    }
    println("YES")
    println(r.mkString(" "))
  }
}


object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val s = readLine

  val x = s.groupBy(identity)
  val max = x.values.exists(_.size > 1)

  println(if (max || s.length == 1) "Yes" else "No")
}


import java.util.Scanner

object Solution {
  def main(args: Array[String]): Unit = {

    val scanner = new Scanner(System.in)
    val n = scanner.nextInt()

    var result = false
    for (number <- 0 to n / 2 if !result) {
      if (isCorrect(number) && isCorrect(n - number))
        result = true
    }

    println(if (result) "YES" else "NO")

    def isCorrect(number: Int): Boolean = number match {
      case n: Int if n <= 0 => false;
      case n: Int => n % 2 == 0
    }
  }
}


import java.util.Scanner

object A2 {

  def solution (x:Int, y:Int) : Int = {
    val a = (1 to x).scan(0)(_ + _)
    var c = y
    if (c>=a.last) c%=a.last
    if (c > 0)
      c - (a.takeWhile(_ <= c).last)
    else
      0
  }

  def main(args: Array[String]): Unit = {
    val reader = new Scanner(System.in)
    println(solution(reader.nextInt(),reader.nextInt()))
  }
}


import java.io._
import java.util.ArrayList
import java.util.StringTokenizer
//import java.math.BigDecimal

object Bitz_D {

  def main(args: Array[String]): Unit = {

    //COMMENT ME !
//    is = new ByteArrayInputStream(Test.sa1.trim.getBytes("ISO-8859-1"))
//    debugV = true

    //---------------------------- parameters reading --------------------------
    br = setupInputOutput();
    val line1 = readLine
    val n = line1.long

    var res = (n*(n+1)) /2
    res = res * 6 + 1
    println(res)

    //---------------------------- parameters reading end ----------------------

  }

  //---------------------------- service code ----------------------------------

  def readLine() = new Line
  class Line {
    val tok = new StringTokenizer(br.readLine(), " ")
    def int = tok.nextToken().toInt
    def long = tok.nextToken().toLong
    def double = tok.nextToken().toDouble
    def string = tok.nextToken()
  }

  var debugV = false
  var is = System.in
  var br = setupInputOutput();
  def db(x: => String) = if (debugV) println(x) // nullary function
  def setupInputOutput(): BufferedReader = {
    val devEnv = this.getClass.getCanonicalName.contains(".")
    if (!devEnv) {
      is = System.in
      debugV = false
    }
    val bis = new BufferedInputStream(is);
    new BufferedReader(new InputStreamReader(bis));
  }

//============================================================================================
object Test {

val sa1 = """
1000 1000000
"""

}

}


object A670 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    if(n%7 == 1) {
      println(s"${2*(n/7)} ${2*(n/7) + 1}")
    } else if(n%7 == 6) {
      println(s"${2*(n/7) + 1} ${2*(n/7) + 2}")
    } else if(n%7 == 0) {
      println(s"${2 * (n/7)} ${2*(n/7)}")
    } else {
      println(s"${2 * (n/7)} ${2 * (n/7) + 2}")
    }
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}


object A {
  def main(args: Array[String]){
    val line1 = readLine().split(":")
    val line2 = readLine().split(":")
    val h1 = line1(0).toInt
    val m1 = line1(1).toInt
    val h2 = line2(0).toInt
    val m2 = line2(1).toInt

    val difHour = h2 - h1
    val difMin = m2 - m1 + (difHour * 60)
    val halfMin = difMin / 2
    val addHour = halfMin / 60
    val addMin = halfMin % 60

    var resHour = h1 + addHour
    var resMin = m1 + addMin
    if (resMin >= 60) {
      resHour += 1
      resMin -= 60
    }

    println("%02d:%02d".format(resHour, resMin))
  }
}


//package eduround61

import scala.io.StdIn

object TaskF extends App {
  val n = StdIn.readInt()
  val s = StdIn.readLine()
  var dp = Array.ofDim[Int](n, n)
  for {
    i <- 0 until n
    j <- 0 until n
  } dp(i)(j) = -1

  println(rec(0, n-1))

  def rec(l: Int, r: Int): Int = {
    if (dp(l)(r) != -1)
      return dp(l)(r)
    if (l > r) {
      return 0
    }
    if (l == r) {
      return 1
    }
    var res = 1 + rec(l+1, r)
    for (i <- l+1 to r if s(i) == s(l)) {
      res = Math.min(res, rec(l+1, i-1) + rec(i, r))
    }
    dp(l)(r) = res
    res
  }

}


//package solutions

import java.io.PrintWriter
import java.util.Scanner

import scala.util.control.Breaks

/**
  * @author traff
  */

object SolTaskA extends App {
  override def main(args: Array[String]): Unit = {
    val out = new PrintWriter(System.out)

    run(new Scanner(System.in), out)

    out.close()
  }

  def run(s: Scanner, out: PrintWriter): Unit = {

    val n = s.nextLine().toInt

    val a = s.nextLine().split(" ").map(_.toInt)
    val b = s.nextLine().split(" ").map(_.toInt)

    var cnt1 = a.foldLeft(Array.fill(5)(0))((a, x) => {
      a(x - 1) += 1
      a
    })

    var cnt2 = b.foldLeft(Array.fill(5)(0))((a, x) => {
      a(x - 1) += 1
      a
    })

    Breaks.breakable {
      val d = cnt1.zip(cnt2).foldLeft(0)((c, t) => {
        val d = math.abs(t._1 - t._2)
        if (d % 2 != 0) {
          out.println(-1)
          Breaks.break()
        }
        c + d / 2
      })

      out.println(if (d % 2 == 0) d / 2 else -1)
    }
  }

}


object Main
{
	def cmp (s1 : Array[Char], s2 : Array[Char]) : Boolean =
	{
		for (i <- 0 until s1.size)
			if (s1(i) != s2(i)) return false
		return true
	}

	def add (s : String, a : Char) : String =
	{
		var s2 = new Array[Char](s.size+2)
		for (i <- 0 until s.size)
			s2(i) = s(i)
		s2(s.size) = a

		println("")
		print ("Ja izgradi nizata: ")
		for (i <- 0 until s2.size)
			print(s2(i))
		println("")

		s2.toString
	}

	def main (args : Array[String]) =
	{
		val m = scala.io.StdIn.readInt

		val mat = Array.ofDim[Int](10,10)
		for (i <- 0 to 6)
			for (j <- 0 to 6)
				mat(i)(j) = 0

		//println("pomina")

		for (i <- 0 until m)
		{
			var a_b = scala.io.StdIn.readLine.split(' ').map(_.toInt)
			var a = a_b(0)
			var b = a_b(1)
			mat(a)(b) = 1
			mat(b)(a) = 1
		}

		var flag = false

		for (i <- 1 to 5)
			for (j <- 1 to 5)
				for (k <- 1 to 5)
					if (i != j && i != k && j != k)
					{
						if (mat(i)(j) == 1 && mat(i)(k) == 1 && mat(j)(k) == 1)
							flag = true
						if (mat(i)(j) == 0 && mat(i)(k) == 0 && mat(j)(k) == 0)
							flag = true
					}

		if (flag == true)
			println("WIN")
		else
			println("FAIL")

	}
}


object Solution {

  def main(args: Array[String]): Unit = {

    val in: Iterator[String] = io.Source.stdin.getLines()
    val n = in.next().toInt
    val s = in.next()

    var res = Int.MaxValue

    val q = s.sliding(4).toList
      q.foreach { current =>
      val Array (a, b, c, d) = current.toArray.map(_ - 'A')
      val aa = changes(a, 'A' - 'A')
      val bb = changes(b, 'C' - 'A')
      val cc = changes(c, 'T' - 'A')
      val dd = changes(d, 'G' - 'A')
      res = Math.min(res, aa + bb + cc + dd)
    }

    println(res)
  }

  def changes(source: Int, target: Int) = {
    Math.min(Math.min(Math.abs(target - source), target + 26 - source), source + 26 - target)
  }

}


/**
  * Created by MZKL7315 on 4/18/2016.
  */
object Main {

  def main(args: Array[String]) = {
    val in = scala.io.Source.stdin.getLines()
    val l = in.next().split(' ').toList
    if (l(0).equals(l(1))) println(l(0))
    else println(1)
  }
}


object P75A extends App{
    val (a,b) = (readLine,readLine)
    def r(s:String) = s.replace("0","").toInt
    println(if(Array(a,b).map(r).sum == r((a.toInt + b.toInt).toString())) "YES" else "NO")
}


import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val Array(a, b) = in.next().split(' ').map(_.toInt)
  println(a + b - (if ((a - b) % 3 == 0 && a * b != 1) 3 else 2))
}


import java.io._
import java.util
import java.util._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val s = next
    val t = next
    val len = s.size
    val s1 = s.toCharArray
    var i = len - 1
    while (i >= 0 && s(i) == 'z') {
      s1(i) = 'a'
      i -= 1
    }
    s1(i) = (s1(i) + 1).toChar
    val res = new String(s1)
    if (res > s && res < t) {
      out.println(res)
      return 1
    }
    out.println("No such string")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}


object A extends App {
  val vs = List('a', 'e', 'u', 'i', 'o', '1', '3', '5', '7', '9')
  val s = scala.io.StdIn.readLine()
  println(s.filter(vs.contains).length)
}


object Main {
    def main(args: Array[String]): Unit = {
        val n = readLong
        if (n == 1) println("1 1")
        else {
        val plist = f1(n)
        //println(plist)
        val compV = plist.foldLeft(Vector[(Long, Long)]((1L, 1L))){
            case (l, x) => l.map{case (i, j) => (i * x, j)} ++ l.map{case (i, j) => (i, j * x)}
        }
        //println(compV)
        val (am, bm) = compV match {
            case (a, b) +: rest => rest.foldLeft((a, b)){
                case ((am, bm), (x, y)) => if (math.max(am, bm) > math.max(x, y)) (x, y) else (am, bm)
            }
        }
        println(am.toString + " " + bm.toString)
       }
    }

    def f1(n: Long): List[Long] = {
        val (ps, np) = (2 to (math.sqrt(n.toDouble) + 1).toInt).foldLeft((List[Long](), n)){
            case ((ls, n), i) => if (n % i == 0) {
                val (is, ni) = f2(n, i)
                (ls :+ is, ni)
            } else (ls, n)
        }
        if (np == 1L) ps else ps :+ np
    }

    def f2(n: Long, i: Long): (Long, Long) = {
        def aux(n: Long, i: Long, t: Long): (Long, Long) = if (n % i != 0) (t, n) else aux(n / i, i, t * i)
        aux(n, i, 1L)
    }
}


import java.util.Scanner

object MainB extends App {
  val sc = new Scanner(System.in)

  def conv(n: Int): List[Int] = {
    def inner(n: Int): List[Int] = {
      if (n < 3) n :: Nil
      else (n % 3) :: inner(n / 3)
    }

    inner(n).reverse
  }

  def sum(a: List[Int], b: List[Int]): List[Int] = {
    val la = List.make(a.size.max(b.size) - a.size, 0) ++ a
    val lb = List.make(a.size.max(b.size) - b.size, 0) ++ b

    val res = for (d <- la zip lb) yield (d._1 + d._2) % 3
    res
  }

  def diff(a: List[Int], c: List[Int]): List[Int] = {
    val la = List.make(a.size.max(c.size) - a.size, 0) ++ a
    val lc = List.make(a.size.max(c.size) - c.size, 0) ++ c

    for(d <- la zip lc) yield (d._2 - d._1 + 3) % 3
  }

  def rest(l: List[Int]): String = {
    val s = for (i <- l.reverse zip Stream.from(0)) yield i._1 * (Math.pow(3, i._2)).toInt
    s.sum.toString()
  }

  val a = sc.nextInt()
  val c = sc.nextInt()
  val ca = conv(a)
  val cc = conv(c)

  println(rest(diff(ca, cc)))
}


object Round213_Div2_Task4 {
  /**
   * Contest 213, Div 2, problem C
   *
   * John Doe has recently found a "Free Market" in his city — that is the
   * place where you can exchange some of your possessions for other things
   * for free.
   *
   * John knows that his city has n items in total (each item is
   * unique). You can bring any number of items to the market and exchange
   * them for any other one. Note that each item is one of a kind and that
   * means that you cannot exchange set {a, b} for set {v, a}. However, you
   * can always exchange set x for any set y, unless there is item p, such
   * that p occurs in x and p occurs in y.
   *
   * For each item, John knows its value ci. John's sense of justice
   * doesn't let him exchange a set of items x for a set of items y, if
   * s(x) + d < s(y) (s(x) is the total price of items in the set x).
   *
   * During one day John can exchange only one set of items for something
   * else. Initially, he has no items. John wants to get a set of items
   * with the maximum total price. Find the cost of such set and the
   * minimum number of days John can get it in.
   *
   * Input The first line contains two space-separated integers n, d
   * (1 ≤ n ≤ 50, 1 ≤ d ≤ 104) — the number of items on the market and
   * John's sense of justice value, correspondingly. The second line
   * contains n space-separated integers ci (1 ≤ ci ≤ 104).
   *
   * Output Print two space-separated integers: the maximum possible price
   * in the set of items John can get and the minimum number of days needed
   * to get such set.
   */

  val inputStreamReader = {
    import java.net.InetAddress
    import java.security.MessageDigest
    import java.io.{ FileInputStream, InputStreamReader, BufferedReader }

    val md = MessageDigest.getInstance("SHA-1")
    val userName = System.getProperty("user.name")
    val hostName = InetAddress.getLocalHost.getHostName

    val bytes = md.digest((userName + hostName).getBytes)
    val sb = new StringBuilder
    for (i ← 0 until bytes.length)
      sb.append(Integer.toString((bytes(i) & 0xff) + 0x100, 16).substring(1))

    val inputStream =
      if (sb.result == "51a302f8ba1abe181e33fe86c0ab4c7bedfb6c91") new FileInputStream("tmp/0.txt")
      else System.in
    new BufferedReader(new InputStreamReader(inputStream))
  }

  def main(args: Array[String]): Unit = {
    import java.util.StringTokenizer

    val (n, d) = {
      val st = new StringTokenizer(inputStreamReader.readLine)
      (st.nextToken.toInt, st.nextToken.toInt)
    }

    val costs = {
      val r = Array.fill(n)(0)
      val st = new StringTokenizer(inputStreamReader.readLine)
      for (i ← 0 until n) r(i) = st.nextToken().toInt
      r
    }
    val sum = costs.sum
    val dp = Array.fill(n + 1)(Array.fill(sum + 1)(false))
    for (i ← 0 until n) dp(i)(0) = true

    for {
      n_i ← 1 to n
      sum_i ← 1 to sum
    } {
      dp(n_i)(sum_i) = dp(n_i - 1)(sum_i)
      if (costs(n_i - 1) <= sum_i) dp(n_i)(sum_i) |= dp(n_i - 1)(sum_i - costs(n_i - 1))
    }

    var cur = 0
    var steps = 0
    var found = true
    while (found) {
      found = false
      for {
        i ← Math.min(cur + d, sum) until cur by -1
        j ← 1 to n
        if !found && dp(j)(i)
      } {
        found = true
        cur = i
        steps += 1
      }
    }
    println(s"$cur $steps")
  }
}


import java.io._
import java.util._

object D {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def nextDouble: Double = {
    return java.lang.Double.parseDouble(next)
  }

  def solve: Int = {
    val n = nextInt
    val p = nextDouble
    val t = nextInt
    val dp = new Array[Array[Double]](n + 1)
    for (i <- 0 to n) {
      dp(i) = new Array[Double](t + 1)
    }
    dp(0)(0) = 1.0d
    for (i <- 1 to t) {
      dp(0)(i) = dp(0)(i - 1) * (1.0d - p)
    }
    for (i <- 1 to n) {
      for (j <- 1 to t) {
        dp(i)(j) += dp(i - 1)(j - 1) * p
        if (i == n) {
          dp(i)(j) += dp(i)(j - 1)
        } else {
          dp(i)(j) += dp(i)(j - 1) * (1.0d - p)
        }
      }
    }
    var ans = 0.0d
    for (j <- 1 to n) {
      ans += dp(j)(t) * j
    }
    out.println(ans)
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}


import scala.util.control.Breaks

object Main extends App {

  val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  //println(a);
  var sum: Long = a;
  var sum2: Long = b;
  var loop = new Breaks;
  loop.breakable {
    for (i <- 1 to 100005) {
      if (i % 2 == 1)
        sum -= i;
      else
        sum2 -= i;
      if (sum < 0) {
        println("Vladik");
        loop.break();
      }
      if (sum2 < 0) {
        println("Valera");
        loop.break();
      }
    }
  }

}


object Solution82A extends App {

  def aaa(n: Int): Int = {
    def seq(n: Int, sum: Int = 0): Stream[(Int, Int)] = (n, sum) #:: seq(n * 2, sum + n)
    val qqq = seq(5)
    val idx = qqq.indexWhere(_._2 > n)
    val last = qqq(idx - 1)
    val count = last._1 / 5
    val offset = n - last._2
    offset / count
  }

  def solution() {
    val names = Map(
      0 -> "Sheldon",
      1 -> "Leonard",
      2 -> "Penny",
      3 -> "Rajesh",
      4 -> "Howard"
    )
    println(names(aaa(_int - 1)))
  }

  //////////////////////////////////////////////////
  import java.util.Scanner
  val SC: Scanner = new Scanner(System.in)
  def _line: String = SC.nextLine
  def _int: Int = SC.nextInt
  def _long: Long = SC.nextLong
  def _string: String = SC.next
  solution()
}


import scala.collection.mutable.ArrayBuffer

object Flask {
  def check(data:ArrayBuffer[ArrayBuffer[Char]], i:Int, j: Int, n: Int, m: Int): Boolean = {
    (data(i)(j) == 'W' && (
    (j + 1 < m  && data(i)(j + 1) == 'P') ||
    (j - 1 >= 0  && data(i)(j - 1) == 'P') ||
    (i + 1 < n  && data(i + 1)(j) == 'P') ||
    (i - 1 >= 0  && data(i - 1)(j) == 'P')))
  }

  def main(args: Array[String]): Unit = {
    var input = readLine.split(" ").map(_.toInt)
    var n = input(0); var m = input(1)
    var data:ArrayBuffer[ArrayBuffer[Char]] = new ArrayBuffer[ArrayBuffer[Char]]()

    (0 until n).foreach(i => {
      data += new ArrayBuffer[Char]()
      readLine.foreach(ch => data(i) += ch)
    })

    var total = 0
    for (i <- 0 to n - 1; j <- 0 to m - 1)
      if (check(data, i, j, n, m))
        total += 1

    println(total)
  }
}


import java.util.Scanner

/**
  * Created by dr0ff on 04/03/16.
  */
object InsomniaCure {

  def main(args: Array[String]): Unit = {
    val in = new Scanner(System.in)
    val k = in.nextInt()
    val l = in.nextInt()
    val m = in.nextInt()
    val n = in.nextInt()
    val dragons = in.nextInt()

    print(countPunchedDragons(dragons, k, l, m, n))
  }

  def countPunchedDragons(dragons: Int, k: Int, l: Int, m: Int, n: Int): Int = {
    val lcmKL = lcm(k, l);
    val lcmKM = lcm(k, m);
    val lcmKN = lcm(k, n);
    val lcmLM = lcm(l, m);
    val lcmLN = lcm(l, n);
    val lcmMN = lcm(m, n);

    dragons / k +
    dragons / l - dragons / lcmKL +
    dragons / m - dragons / lcmKM - dragons / lcmLM +
      dragons / lcm(lcmKM, lcmLM) +
    dragons / n - dragons / lcmKN - dragons / lcmLN - dragons / lcmMN +
      dragons / lcm(lcmKN, lcmLN) + dragons / lcm(lcmKN, lcmMN) + dragons / lcm(lcmLN, lcmMN) -
      dragons / lcm(lcm(lcmKN, lcmLN), lcmMN)
  }

  /**
    * Return greatest common divisor using Euclid's Algorithm.
    * @param a
    * @param b
    * @return greates common divisor of a and b
    */
  def gcd(a: Int, b: Int): Int =
    if (b > 0)
      gcd(b, a % b)
    else
      a

  /**
    * Return lowest common multiple.
    * @param a
    * @param b
    * @return lowest common multiple of a and b
    */
  def lcm(a: Int, b: Int): Int =
    a * b / gcd(a, b)
}


object A {
  def gcd(a: Int, b: Int): Int = { if (a<b) gcd(b, a) else if (b==0) a else gcd(b,a%b) }
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt();
    val in = Array.fill(n)(sc.nextInt())

    println(in.foldLeft(0)(gcd(_, _)) * n)
  }
}


object A {
  def main(args: Array[String]) = {
    solve
  }
  def solve = {
    var n = readLine().toInt
    var ans = 0
    for (e <- (1 to n).map(i => i * (i + 1) / 2)) {
      if (e <= n) {
        n -= e
        ans += 1
      }
    }
    println(ans)
  }
}


object C
{
  val mod = 1000000007L

  def main(args: Array[String])
  {
    val n = readLong
    val powN = pow(2,n)
    println(powN*(powN+1)/2%mod)
  }
  def pow(a: Long, b: Long): Long =
  {
    if(b==0) 1L
    else if(b%2==1) (a*pow(a,b-1))%mod
    else
    {
      val sqrt = pow(a,b/2)
      (sqrt*sqrt)%mod
    }
  }
}


import scala.io.StdIn

object Test {
  def main(args: Array[String]): Unit = {
    StdIn.readLine
    println(StdIn.readLine.split(' ').map(_.toInt).sorted.toList.grouped(2).toList.map{_.reduce{_ - _}}.sum.abs)
  }
}


import java.util.StringTokenizer

import scala.Ordering
import scala.collection.mutable

object C extends App {
  val INF = 1 << 30
  var st: StringTokenizer = _
  def read() = { st = new StringTokenizer(readLine()) }
  def int() = st.nextToken().toInt

  read()
  val n = int()

  case class Card(id: Int, red: Boolean, rCost: Int, bCost: Int)
  val cards: Array[Card] = (0 until n).map { k =>
    read()
    Card(k, st.nextToken() == "R", int(), int())
  }.toArray

  case class State(redCost: Int, blueCost: Int)
  val ord = new Ordering[State] {
    override def compare(x: State, y: State): Int = x.redCost - y.redCost
  }
  var states = new Array[List[State]](1 << n)

  states(0) = List(State(0, 0))

  (1 until (1 << n)).foreach { stateId =>
    val intCards = cards.filter(card => ((1 << card.id) & stateId) != 0)
    val rCards = intCards.count(_.red)
    val bCards = intCards.length - rCards
    val arr = mutable.ArrayBuilder.make[State]
    intCards.foreach { card =>
      val preState = stateId ^ (1 << card.id)
      val redCost = Math.max(0, card.rCost - rCards + (if (card.red) 1 else 0) )
      val blueCost = Math.max(0, card.bCost - bCards + (if (card.red) 0 else 1) )
      states(preState).foreach { pre =>
        arr += State(pre.redCost + redCost, pre.blueCost + blueCost)
      }
    }
    val newStates = arr.result()
    java.util.Arrays.sort(newStates, ord)

    var list = List.empty[State]
    list = newStates.reduceLeft { (last, cur) =>
      if (last.redCost <= cur.redCost && last.blueCost <= cur.blueCost) last
      else if (last.redCost >= cur.redCost && last.blueCost >= cur.blueCost) cur
      else { list = last :: list; cur }
    } :: list
    states(stateId) = list
  }

  val finalStates = states((1<<n)-1)
  val ans = n + finalStates.map(s => Math.max(s.redCost, s.blueCost)).min
  println(ans)

}


/**
  * Created by octavian on 07/02/2016.
  */
object Kefir {

  def main(args: Array[String]) = {

    //System.setIn(new FileInputStream("./src/kefir.in"))
    //System.setOut(new PrintStream(new FileOutputStream("./src/kefir.out")))

    val n: Long = readLong()
    val a: Long = readLong()
    val b: Long = readLong()
    val c: Long = readLong()

    if(a <= (b - c)) {
      println(n/a)
    }
    else {
      var used: Long = (n - b)/(b - c)
      while(n - used*(b - c) >= b) {
        used += 1
      }
      used = Math.max(used, 0)
      used += (n - used*(b - c))/a
      println(used)
    }

  }

}


object A{
  def main(args: Array[String]){

    val n =readLine.toInt
    val a =readLine.split(" ").toList.map(_.toInt)

    val name =Array[String]("chest", "biceps", "back")
    val sum =Array[Int](0,0,0)

    var max=0
    var midx=0
    for((aa,i) <- a.zipWithIndex){
      val ii=i%3
      sum(ii)+=aa
      if(max<sum(ii)){
        max=sum(ii)
        midx=ii;
      }
    }

    println(name(midx))
  }
}


import scala.io.StdIn._
import scala.math._

object Incident {

  def main(args : Array[String]){

  var in=readLine.split(' ')
  var  t=in(0).toLong
  var  s=in(1).toLong
  var  x=in(2).toLong
  if(x>=t+s)
	{
	if((x-t)%s==0 || (x-1-t)%s==0)  printf("YES\n")
	else printf("NO\n")
	}
	else
	{
		if(x==t) printf("YES\n")
		else printf("NO\n")
	}
}
}


object Solution extends App {
  val in = io.Source.stdin.getLines()
  val n = in.next().toInt
  val (m, s) = in.next().split(' ').map(_.toInt).foldLeft((0, 0)) {
      case ((max, state), 0) =>
        (max, 0)
      case ((max, 0), 3) =>
        (max + 1, 0)
      case ((max, 0), el) =>
        (max + 1, el)
      case ((max, 1), 3) =>
        (max + 1, 2)
      case ((max, 2), 3) =>
        (max + 1, 1)
      case ((max, 2), 0) =>
        (max + 1, 0)
      case ((max, state), el) if state == el =>
        (max, 0)
      case ((max, state), el) =>
        (max + 1, el)
  }
  println(n - m)
}


object Main {
  //import java.io.{BufferedReader, InputStreamReader}

  val out = new java.io.PrintWriter(System.out, false)
  //val in = new BufferedReader(new InputStreamReader(System.in))

  def nextInt(): Int = Integer.parseInt(scala.io.StdIn.readLine)
  def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; val a = new Array[Int](n); for (i <- a.indices) a(i) = Integer.parseInt(tl.nextToken); a }

  def main(args: Array[String]): Unit = {
    val n = nextInt()
    //val Array(n) = readInts(1)
    val (a, b) = n % 4 match {
      case 0 => (1, 'A')
      case 1 => (0, 'A')
      case 2 => (1, 'B')
      case 3 => (2, 'A')
    }
    out.println(s"$a $b")
    out.flush()
  }

}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()

  val data = in.next().split(' ').map(_.toLong).sorted
  if (data.last > 2 * (data(0) + data(1)))
    println(data(0) + data(1))
  else {
    println(data.sum / 3)

  }

}


import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _659A extends CodeForcesApp {
  override def apply(io: IO) = {
    val n, a, b = io[Int]
    val m = (a + b) % n
    io += (if (m <= 0) n + m else m)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sum[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
  }
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def  asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default
  }
  def memoize[I] = new {
    def apply[O](f: I => O): I => O = new mutable.HashMap[I, O]() {
      override def apply(key: I) = getOrElseUpdate(key, f(key))
    }
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  val mod: Int = (1e9 + 7).toInt
  val newLine: String = "\n"
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    if (tokenizers.nonEmpty) Some(tokenizers.head) else None
  }

  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)
  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def appendNewLine(): this.type = {
    println()
    this
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}


import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P118D extends App {
  def solve(n1: Int, n2: Int, k1: Int, k2: Int): Long = {
    val cache = mutable.Map.empty[(Int, Int), Long]

    def dp(a: Int, b: Int): Long =
      if (a < 0 || b < 0) 0
      else if (a == 0) { if (b == 0) 1 else 0 }
      else if (b == 0) { if (a <= k1) 1 else 0 }
      else {
        val pair = (a, b)
        if (cache.contains(pair)) cache(pair)
        else {
          @tailrec
          def loop(acc: Long, i: Int, j: Int): Long =
            if (i == a) acc
            else if (j == b) loop(acc, i + 1, b - k2)
            else loop(acc + dp(i, j), i, j + 1)
          val x = loop(0, a - k1, b - k2) % 100000000L
          cache += (pair -> x)
          x
        }
      }
    dp(n1, n2)
  }

  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val n1, n2, k1, k2 = sc.nextInt
  val answer = (solve(n1, n2, k1, k2) + solve(n2, n1, k2, k1)) % 100000000L
  out.println(answer)
  out.close
}