object Solution {
  def main(args: Array[String]) = {
    val s = readLine.toList

    val as = s.filter(_ == 'a').length
    val bs = s.filter(_ == 'b').length
    val cs = s.filter(_ == 'c').length
    val d = s.dropWhile(_ == 'a').dropWhile(_ == 'b').dropWhile(_ == 'c').isEmpty

    println(if (d && as > 0 && bs > 0 && cs > 0 && (as == cs || bs == cs)) "YES" else "NO")
  }
}

import java.io._
import java.nio.file._
import java.util.StringTokenizer

import scala.io.Codec

object CheckString {

  def solve(scanner: Scanner) = {
    val word = scanner.nextLine()
    try {
      val splitResult = word.split("b+")
      val aWord = splitResult(0)
      val cWord = splitResult(1)
      val bWord = word.substring(aWord.size, word.size - cWord.size)

      val aSet = aWord.toSet
      val bSet = bWord.toSet
      val cSet = cWord.toSet
      if (aSet.contains('a') && bSet.contains('b') && cSet.contains('c')) {
        if (aSet.size != 1 || bSet.size != 1 || cSet.size != 1) {
          println("NO")
        } else {
          if (aWord.size == cWord.size || bWord.size == cWord.size) {
            println("YES")
          } else {
            println("NO")
          }
        }
      } else {
        println("NO")
      }
    } catch {
      case t: Throwable =>
        println("NO")
        System.err.println(t)
    }
  }

  def main(args: Array[String]): Unit = {
    if (args.length > 0) {
      val filenameIn = args(0)
      System.setIn(new FileInputStream(filenameIn))
    }
    val scanner = new Scanner(System.in)
    if (args.length > 1) {
      val filename = args(1)
      System.setOut(new PrintStream(filename))
    }
    val start = System.currentTimeMillis
    solve(scanner)
    scanner.close()
    System.err.println("\n" + (System.currentTimeMillis - start) + " ms")
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {
    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = Iterator.continually(reader.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).filter(_.hasMoreTokens)
    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {
      current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
      current
    }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
      * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

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

    override def hasNext = tokenizer().nonEmpty

    override def close() = reader.close()
  }

}

object Solution {
  def main(args: Array[String]) = {
    val s = readLine.toList

    val as = s.filter(_ == 'a').length
    val bs = s.filter(_ == 'b').length
    val cs = s.filter(_ == 'c').length
    val d = s.takeWhile(_ == 'a').takeWhile(_ == 'b').takeWhile(_ == 'c').isEmpty

    println(if (d && as > 0 && bs > 0 && cs > 0 && (as == cs || bs == cs)) "YES" else "NO")
  }
}


object ProblemC extends App {
  import java.io.{BufferedReader, InputStreamReader, PrintWriter}
  import java.util.StringTokenizer

  import scala.collection.mutable
  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))
  val out = new PrintWriter(System.out)

  class FastScanner(val in: BufferedReader) {
    var st: StringTokenizer = _;

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

    def nextInt(): Integer = {
      Integer.parseInt(nextToken());
    }

    def nextLong(): Long = {
      nextToken().toLong;
    }

    def nextDouble(): Double = {
      nextToken().toDouble;
    }
  }

  val n = in.nextInt()

  for (_ <- 1 to n) {
    val n = in.nextInt()
    val arr = new Array[Boolean](n)
    var result = true
    for (j <- 0 until n) {
      val ak = in.nextInt()

      var place = (n + (j + ak) % n) % n

      if (arr(place)) {
        result = false
      }

      arr(place) = true
    }

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

}

object C extends App {
  private def mod(k: Int, n: Int): Int =
    if (k > 0) k % n else (n - k % n) % n

  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val n  = scala.io.StdIn.readInt()
    val an = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val bm = an.zipWithIndex.map { case (a, i) => (n + (a + i) % n) % n }.distinct

    if (n == bm.length) println("YES")
    else println("NO")
  }
}

object Codeforces1344a {

  import java.io.{BufferedReader, PrintStream}

  import scala.io.Source

  def main(args: Array[String]): Unit = {
    exec(Source.stdin.bufferedReader, System.out)
  }

  def exec(implicit
           reader: BufferedReader,
           writer: PrintStream): Unit = {
    val t: Int = rl_int
    (1 to t).foreach { _ =>
      if (test()) {
        writer.println("YES")
      } else {
        writer.println("NO")
      }
    }
  }

  def test()(implicit reader: BufferedReader): Boolean = {
    val n: Int = rl_int
    val a: Array[Int] = rll_int
    a.zipWithIndex.map(x => Math.floorMod(x._1 + x._2, n)).distinct.length == n
  }

  def rl(implicit reader: BufferedReader): String = reader.readLine
  def rll(implicit reader: BufferedReader): Array[String] = reader.readLine.split(' ')

  def rl_bool(implicit reader: BufferedReader): Boolean = rl.toBoolean
  def rl_byte(implicit reader: BufferedReader): Byte = rl.toByte
  def rl_short(implicit reader: BufferedReader): Short = rl.toShort
  def rl_int(implicit reader: BufferedReader): Int = rl.toInt
  def rl_long(implicit reader: BufferedReader): Long = rl.toLong
  def rl_float(implicit reader: BufferedReader): Float = rl.toFloat
  def rl_double(implicit reader: BufferedReader): Double = rl.toDouble

  def rll_bool(implicit reader: BufferedReader): Array[Boolean] = rll.map(_.toBoolean)
  def rll_byte(implicit reader: BufferedReader): Array[Byte] = rll.map(_.toByte)
  def rll_short(implicit reader: BufferedReader): Array[Short] = rll.map(_.toShort)
  def rll_int(implicit reader: BufferedReader): Array[Int] = rll.map(_.toInt)
  def rll_long(implicit reader: BufferedReader): Array[Long] = rll.map(_.toLong)
  def rll_float(implicit reader: BufferedReader): Array[Float] = rll.map(_.toFloat)
  def rll_double(implicit reader: BufferedReader): Array[Double] = rll.map(_.toDouble)

}

object C extends App {
  private def mod(k: Int, n: Int): Int =
    if (k > 0) k % n else (n - k % n) % n

  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val n  = scala.io.StdIn.readInt()
    val an = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val bm = an.zipWithIndex.map { case (a, i) => mod(a + i, n) }.distinct

    if (n == bm.length) println("YES")
    else println("NO")
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val n  = scala.io.StdIn.readInt()
    val an = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val bn = an.zipWithIndex.map { case (a, i) => (a + i % n) % n }.distinct

    if (an.length == bn.length) println("YES")
    else println("NO")
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val n  = scala.io.StdIn.readInt()
    val an = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val bn = an.zipWithIndex.map { case (a, i) => (a + i) % n }.distinct

    if (an.length == bn.length) println("YES")
    else println("NO")
  }
}


object Holidays44C  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 watered= Array.fill(n)(0)

    (1 to m).foreach(_ => {
      val a = scanner.nextInt()-1
      val b = scanner.nextInt()-1
      (a to b).foreach(d => watered(d) += 1)
    })
    val result = watered.zipWithIndex.find { case (w, _) => w != 1 }
    val strResult = result.map{
      case (w,day) => s"${day+1} $w"
    }.getOrElse("OK")

    out.println(strResult)

  }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val Array(n, m) = in.next().split(' ').map(_.toInt)
  val answer = Array.ofDim[Int](n + 1)
  in.take(m).map(_.split(' ').map(_.toInt - 1)).foreach{i =>
    answer(i.head) += 1
    answer(i.last + 1) -= 1
  }

  val (index, count, _) = (0 until n).foldLeft((-1, -1, 0)) {
    case ((-1, _, soFar), i) =>
      val nSoFar = soFar + answer(i)
      if (nSoFar < 1)
        (i, 0, 0)
      else if (nSoFar > 1)
        (i, nSoFar, 0)
      else
        (-1, -1, nSoFar)
    case (acc, el) => acc
  }

  if (index == -1)
    println("OK")
  else
    println(s"${index + 1} $count")
}


object CF918A extends App{
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  def fibooo(a: Int, b:Int) :Stream[Int] = a #:: fibooo(b, a + b)
  val fibooo1000 = fibooo(1, 1).takeWhile(_ <= 1000)
  println(Range(1, n + 1) map (i => if(fibooo1000 contains i) 'O' else 'o') mkString(""))
}

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

  def name(c: Int = 1, i: Int = 1, j: Int = 1, r: String = ""): String =
    if (c > n) r
    else if (c == 1) name(c + 1, i, j, r + "O")
    else {
      val t = i + j
      if (c == t) name(c + 1, t, i, r + "O")
      else name(c + 1, i, j, r + "o")
    }

  println(name())
}

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

  override def apply(io: IO): io.type = {
    val fib = Set(1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987)
    val n = io.read[Int]

    val ans = (1 to n).map(i => if (fib(i)) 'O' else 'o')

    io.write(ans.mkString)
  }
}
/****************************[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 = 0, until: Int = a.length)(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 = 0, until: Int = a.length)(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]).withDefaultValue(b().result())
    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 getBit(i: Int): Int = (x >> i) & 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 getBit(i: Int): Long = (x >> i) & 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
      }
    }
  }
}


import scala.io.StdIn

object Maximums {
  // https://codeforces.com/problemset/problem/1326/B
  def main(args: Array[String]): Unit = {
    val nums = StdIn.readInt()
    val arrB = StdIn.readLine().split(" ").map(_.toInt)

    var currMax = 0
    val arrA = arrB.map { b =>
      val a = b + currMax
      currMax = math.max(currMax, a)
      a
    }

    println(arrA.mkString(" "))
  }

}

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

  override def solve(io: IO) = {
    val bs = io.read[Seq[Int]]

    var a = 0
    val ans = bs map {b =>
      val ai = b + a
      a = max(a, ai)
      ai
    }

    io.writeAll(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 solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]

  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)

  implicit class GenericExtensions[A](a: A) {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }

  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](t: C[A]) {
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]

    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)

    def toMultiSet(withDefaultZero: Boolean): Map[A, Int] = {
      val freqTable = t.groupBy(identity).mapValues(_.size)
      if (withDefaultZero) freqTable.withDefaultValue(0) else freqTable
    }
  }

  implicit class PairExtensions[A, B](p: (A, B)) {
    def key = p._1
    def value = p._2
    def toSeq(implicit ev: B =:= A): Seq[A] = Seq(p.key, ev(p.value))
  }

  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C]).withDefaultValue(b().result())
  }

  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](m: C[K, V]) {
    def toMutable: mutable.Map[K, V] = mutable.Map.empty[K, V] ++ m
  }

  implicit class SetExtensions[A, C[A] <: Set[A]](s: C[A]) {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    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)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    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 {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

  def desc[A](implicit order: Ordering[A]): Ordering[A] = order.reverse  //e.g. students.sortBy(_.height)(desc)

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[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
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]
  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

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

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

  def repeat(f: => Unit): Unit = Utils.repeat(read[Int]){f; writeLine()}

  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: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    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 {

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

  import scala.collection.mutable
  import scala.collection.mutable.ListBuffer
  def main(args: Array[String]): Unit = {
    solve(System.in,System.out)
  }
  def solve(inputStream: InputStream, out: PrintStream): Unit = {
    val in = new InputReader(inputStream)
    val n = in.nextInt()
    val res = Array.fill(n)(0)
    var max = 0
    (0 until n).foreach{i =>
      val b = in.nextInt()
      val a = b+max
      max = Math.max(max,a)

      res(i) = a
    }
    out.println(res.mkString(" "))
  }
  class InputReader(stream: InputStream){
    val reader: BufferedReader = new BufferedReader(new InputStreamReader(stream),32768)
    var tokenizer: StringTokenizer = _
    def next(): String = {
      while(tokenizer == null || !tokenizer.hasMoreTokens){
        try{
          tokenizer = new StringTokenizer(reader.readLine())
        }catch {
          case e: IOException => throw new RuntimeException(e)
        }
      }
      tokenizer.nextToken()
    }
    def nextInt(): Int =  next().toInt
    def nextLong(): Long =  next().toLong
  }
}


object CF611B extends App {

  import scala.io.StdIn

  val q = StdIn.readInt
  for (_ <- 0 until q) {
    val Array(n, k) = StdIn.readLine.split(' ').map(_.toInt)

    val rest = n%k
    println(n - n%k + Math.min(k/2, rest))
  }
}

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

  val t = stdin.next().toInt
  println(stdin.take(t).map(_.split(" ").map(_.toInt)).map(arr => calc(arr(0), arr(1))).mkString("\n"))

  def calc(bonbons: Int, kids: Int): Int = bonbons / kids * kids + Math.min(bonbons % kids, kids / 2)
}

case class Trap(l: Int, r: Int, d: Int)

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

  val t = stdin.next().toInt
  println(stdin.take(t).map(_.split(" ").map(_.toInt)).map(arr => calc(arr(0), arr(1))).mkString(" "))

  def calc(hours: Int, minutes: Int): Int = (23 - hours) * 60 + (60 - minutes)
}


import java.util.Scanner

object Main {

	def main(args: Array[String]): Unit = {
		val scanner = new Scanner (System.in)
		val n = scanner nextInt ()
		val p = List.tabulate (n) (i => scanner nextInt ())
		val ans = (p.sum: Double) / n
		println (ans)
	}

}

import scala.io.StdIn

object A extends App {

  val n = StdIn.readInt()
  val arr = StdIn.readLine().split(" ").map(_.toDouble)
  println(arr.sum/n)

}

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

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

  val N = sc.nextInt

  val answer: Double = List.fill(N)(sc.nextInt).sum * 1.0 / N

  out.println(answer)
  out.close
}

object BDrinks extends App {
  import scala.io.StdIn._

  val n  = readInt()
  val pn = readLine().split(" ").map(_.toInt)

  val ans = pn.sum.toDouble / n

  println(ans)
}

import java.io._
import java.util.Locale
import scala.annotation.tailrec

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInt = reader.readLine().toInt
  def readInts = reader.readLine().split(" ").map(_.toInt)
  def readLongs = reader.readLine().split(" ").map(_.toLong)

  val n = readInt
  def ans = readInts.map(_.toDouble).sum / n

  def main(a: Array[String]) {
    println("%.10f".formatLocal(Locale.US, ans))
  }
}

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

/**
  * 200 B. Drinks
  *
  * Created by yamaton on 11/19/15.
  */

object CF200B {

  def main(args: Array[String]) {
    val n = io.StdIn.readInt()
    val xs = io.StdIn.readLine.split(" ").map(_.toInt).toSeq
    assert(xs.length == n)
    val ans = solve(xs)
    println("%.12f".format(ans))
  }

  def solve(xs: Seq[Int]): Double = {
    xs.sum.toDouble / xs.length
  }

}

import java.util.StringTokenizer

object _200B extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val sum = (1 to n).map(i => next.toInt).sum
  printf("%.14f".format(1.0 * sum / n))
}

object Solution extends App {

  val in = scala.io.Source.stdin.getLines()
  in.next()
  val d = in.next().split(" ").map(_.toInt)
  println(d.sum.toDouble / d.length)
}

import java.util.Scanner

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

  val n = sc.nextInt()
  val values = for (i <- 1 to n) yield sc.nextInt()
  println(values.sum.toDouble / values.length)
}


import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val LeftInf = 10L * Int.MinValue
  val RightInf = 10L * Int.MaxValue
  val a = LeftInf +: readLine().split(" ").map(_.toLong) :+ RightInf
  for (i <- 1 to n) {
    val max = (a(i) - a(1)) max (a(n) - a(i))
    val min = (a(i) - a(i - 1)) min (a(i + 1) - a(i))
    println(min + " " + max)
  }
}

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

import scala.collection.mutable

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)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val cities = new Array[Int](n)
    val min = new Array[Int](n)
    val max = new Array[Int](n)
    for (i <- 0 until n) {
      cities(i) = nextInt
    }
    for (i <- 1 until n - 1) {
      min(i) = Math.min(cities(i + 1) - cities(i), cities(i) - cities(i - 1))
      max(i) = Math.max(cities(n - 1) - cities(i), cities(i) - cities(0))
    }
    min(n - 1) = cities(n - 1) - cities(n - 2)
    max(n - 1) = cities(n - 1) - cities(0)
    min(0) = cities(1) - cities(0)
    max(0) = cities(n - 1) - cities(0)
    for (i <- 0 until n) {
      println(min(i) + " " + max(i))
    }
    return 0
  }
}

import io.StdIn._

object Solution {

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

    for ((c, i) <- cities.zipWithIndex) {
      if (i == 0) println((cities(i+1) - c) + " " + (cities.last - c))
      else if (i == cities.length - 1) println((c - cities(i-1)) + " " + (c - cities.head))
      else println(Math.min(cities(i+1) - c, c - cities(i-1)) + " " + Math.max(cities.last - c, c - cities.head))
    }

  }

}

import annotation.tailrec, collection.mutable, util.control.Breaks._, math.Ordering.Implicits._
import CodeForcesApp._
object _567A extends CodeForcesApp[Seq[String]]({scanner => import scanner._
  val n = nextInt
  val p = IndexedSeq.fill(n)(nextInt)
  for {
    i <- p.indices
  } yield {
    def d(x: Int) = (p(i) - p(x)).abs
    val (u, v) = if(i == 0) {
      d(1) -> d(n-1)
    } else if (i == n-1) {
      d(n-2) -> d(0)
    } else {
      (d(i-1) min d(i+1)) -> (d(0) max d(n-1))
    }
    s"$u $v"
  }
}) {
  override def format(result: Seq[String]) = result.mkString("", "\n", "")
}
import java.util.Scanner
abstract class CodeForcesApp[A](solver: Scanner => A) {
  final def apply(problem: String): String = apply(new Scanner(problem))
  final def apply(scanner: Scanner): String = format(solver(scanner))
  def format(result: A): String = result.toString
  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
object CodeForcesApp {
  import scala.collection.mutable.{Map => Dict}
  final def isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  final val modulus: Int = 1000000007
  final val eps: Double = 1e-9
  final def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  final def counter[A]: Dict[A, Int] = Dict.empty[A, Int] withDefaultValue 0
}

import scala.io.StdIn._

object A extends App {
  readLine()
  val x = readLine().split(" ").map(_.toInt)

  val LastIndex = x.length - 1

  for (i <- x.indices) {
    val min = i match {
      case 0 => Math.abs(x(0) - x(1))
      case LastIndex => Math.abs(x(i - 1) - x(i))
      case _ => Math.min(Math.abs(x(i) - x(i - 1)), Math.abs(x(i) - x(i + 1)))
    }

    val max = Math.max(Math.abs(x(0) - x(i)), Math.abs(x.last - x(i)))

    println(s"$min $max")
  }

}

import java.util.Scanner
import scala.annotation._
import scala.math._

object Solution {
  def main(args: Array[String]) {
    val scanner = new Scanner(System.in)

    val n = scanner.nextInt

    val nums = Array.fill(n)(scanner.nextLong)

    println(s"${nums(1)-nums(0)} ${nums(n-1)-nums(0)}")

    for (i <- 1 until (n-1)) {
      val minCost = min(nums(i)-nums(i-1), nums(i+1)-nums(i))
      val maxCost = max(nums(n-1)-nums(i), nums(i)-nums(0))
      println(s"$minCost $maxCost")
    }

    println(s"${nums(n-1)-nums(n-2)} ${nums(n-1)-nums(0)}")
  }
}

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

import Math.min
import Math.max

object LinelandMail {

   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 main(args: Array[String]) : Unit = {
     val n = readInt
     val xs = readInts
     val first = xs(0)
     val last = xs(n-1)
     println( xs(1)-first + " " + (last-first))
     xs.zipWithIndex.tail.init.foreach {
       case (x,i) =>
         println( min(x-xs(i-1),xs(i+1)-x) + " "
                  + max(x-first,last-x)  )
     }
     println( last - xs(n-2) + " " + (last-first))
   }

}

// package c567.a
object Solution extends App {
  import scala.io.StdIn
  import scala.math.{min, max}
  val n = StdIn.readInt()
  val xs = StdIn.readLine().split(" ").map(_.toInt).toVector
  val first = xs.head
  val last = xs.last
  def m(i: Int, ai: Int): Unit = ()
  println(s"${xs.tail.head - first} ${last - first}")
  xs.zipWithIndex
    .slice(1, xs.length - 1)
    .foreach { case (a: Int, i: Int) ⇒
      println(s"${min(a - xs(i - 1), xs(i + 1) - a)} ${max(a - first, last - a)}")
    }
  println(s"${last - xs(xs.size - 2)} ${last - first}")
}

import scala.io.StdIn._

object CF567A extends App {
  val n = readInt()
  val x = readLine().split(" ").map(_.toLong)

  for (i <- 0 to x.length - 1) {
    val max = Math.max(Math.abs(x(i) - x.head), Math.abs(x.last - x(i)))
    val min = Math.min(
      Math.abs(x(i) - x.lift(i - 1).getOrElse(Long.MinValue)),
      Math.abs(x.lift(i + 1).getOrElse(Long.MaxValue) - x(i))
    )
    println(min + " " + max)
  }
}

import java.util.Scanner
import Array._

object Codeforces extends App {
  val in = new Scanner(System.in)
  val n = in.nextInt()
  val x = ofDim[Long](n + 2)
  x(0) = (-1e18).toLong
  x(n + 1) = (1e18).toLong
  for (i <- 1 to n) {
    x(i) = in.nextLong()
  }
  for (i <- 1 to n) {
    var p = math.min(x(i) - x(i - 1), x(i + 1) - x(i))
    var q = math.max(x(i) - x(1), x(n) - x(i))
    printf("%d %d\n", p, q)
  }
}

object A567 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.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))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val input = readLongs(n)
    val ans = Array.fill(n){Array(Long.MaxValue, 0L)}
    for(i <- 0 until n) {
      // min
      if(i-1 >= 0) {
        ans(i)(0) = math.min(ans(i)(0), math.abs(input(i) - input(i-1)))
      }
      if(i+1 < n) {
        ans(i)(0) = math.min(ans(i)(0), math.abs(input(i) - input(i+1)))
      }
      // max
      if(i != 0) {
        ans(i)(1) = math.max(ans(i)(1), math.abs(input(i) - input(0)))
      }
      if(i != n-1) {
        ans(i)(1) = math.max(ans(i)(1), math.abs(input(i) - input(n-1)))
      }
    }
    println(ans.map(_.mkString(" ")).mkString("\n"))
  }
}

object A extends App {
 val n = readLine.toInt
 val str = readLine
 val arr = str.split(" ").map(_.toInt)
 val mn = arr(0)
 val mx = arr(n - 1)

 import scala.math._

 print(arr(1) - arr(0))
 print(" ")
 println(mx - arr(0))

 for(i <- (1 until n - 1)) {
    print(min(abs(arr(i) - arr(i-1)), abs(arr(i + 1) - arr(i))))
    print(" ")
    println(
            max(
                abs(arr(i) - mn),
                abs(mx - arr(i))
               )
           )
 }

 print(mx - arr(n - 2))
 print(" ")
 println(mx - mn)
}

// So you like object Task
import java.io.{IOException, InputStream, PrintWriter}
import java.util.InputMismatchException

object Task {

    def solve(in: InputReader, out: PrintWriter): Unit = {
        val n = in.nextInt()
        val a = Array.fill(n)(in.nextInt())
        for (i <- 0 until n) {
            val minCost = (if (i == 0) Long.MaxValue else (a(i) - a(i - 1)).abs) min (if (i == n - 1) Long.MaxValue else (a(i) - a(i + 1)).abs)
            val maxCost = (if (i == 0) Long.MinValue else (a(i) - a(0)).abs) max (if (i == n - 1) Long.MinValue else (a(i) - a(n - 1)).abs)
            println("%d %d".format(minCost, maxCost))
        }
    }

    def main(args: Array[String]) {
        val in = new InputReader(System.in)
        val out = new PrintWriter(System.out)

        solve(in, out)

        in.close()
        out.close()
    }
}

class InputReader(val inputStream: InputStream) {
    val buf = new Array[Byte](1 << 16)
    var curChar = 0
    var numChars = 0

    def read(): Int = {
        if (numChars == -1) {
            throw new InputMismatchException()
        }
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = inputStream.read(buf)
            } catch  {
                case _: IOException => throw new InputMismatchException()
            }
            if (numChars <= 0)
                return -1
        }
        curChar += 1
        buf(curChar - 1)
    }

    def peek(): Int = {
        if (numChars == -1) {
            return -1
        }
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = inputStream.read(buf)
            } catch {
                case _: IOException => return -1
            }
            if (numChars <= 0)
                return -1
        }
        buf(curChar)
    }

    def isSpaceChar(c: Int): Boolean = c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1

    def nextInt(): Int = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException()
            res *= 10
            res += c & 15
            c = read()
        } while (!isSpaceChar(c))
        res * sgn
    }

    def nextLong(): Long = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0l
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException()
            res *= 10
            res += c & 15
            c = read()
        } while (!isSpaceChar(c))
        res * sgn
    }

    def next(): String = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        val res = new StringBuilder()
        do {
            res += c.toChar
            c = read()
        } while(!isSpaceChar(c))
        res.toString()
    }

    def nextChar(): Char = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        c.toChar
    }

    //noinspection AccessorLikeMethodIsEmptyParen
    def hasNext(): Boolean = {
        var value = peek()
        do {
            read()
            value = peek()
        } while (isSpaceChar(value) && value != -1)
        value != -1
    }

    def rawNextLine(): String = {
        val builder = new StringBuilder
        var c = read()
        while (c != '\n' && c != -1) {
            if (c != '\r')
                builder += c.toChar
            c = read()
        }
        builder.toString()
    }

    def nextLine(): String = {
        var s = rawNextLine()
        while (s.trim().length == 0) s = rawNextLine()
        s
    }

    def nextDouble(): Double = {
        next().toDouble
    }

    def close(): Unit = {
        inputStream.close()
    }
}

import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val a = Int.MinValue.toLong +: readLine().split(" ").map(_.toLong) :+ Int.MaxValue.toLong
  for (i <- 1 to n) {
    val max = (a(i) - a(1)) max (a(n) - a(i))
    val min = (a(i) - a(i - 1)) min (a(i + 1) - a(i))
    println(min + " " + max)
  }
}

import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val a = Int.MinValue +: readLine().split(" ").map(_.toInt) :+ Int.MaxValue
  for (i <- 1 to n) {
    val max = (a(i) - a(1)) max (a(n) - a(i))
    val min = (a(i) - a(i - 1)) min (a(i + 1) - a(i))
    println(min + " " + max)
  }
}

import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val a = Long.MinValue +: readLine().split(" ").map(_.toLong) :+ Long.MaxValue
  for (i <- 1 to n) {
    val max = (a(i) - a(1)) max (a(n) - a(i))
    val min = (a(i) - a(i - 1)) min (a(i + 1) - a(i))
    println(min + " " + max)
  }
}

import scala.io.StdIn._

object CF567A extends App {
  val n = readInt()
  val x = readLine().split(" ").map(_.toInt)

  for (i <- 0 to x.length - 1) {
    val max = Math.max(x(i) - x.head, x.last - x(i))
    val min = Math.min(x(i) - x.lift(i - 1).getOrElse(Int.MaxValue), x.lift(i + 1).getOrElse(Int.MaxValue) - x(i))
    println(min + " " + max)
  }
}

import scala.io.StdIn._

object CF567A extends App {
  val n = readInt()
  val x = readLine().split(" ").map(_.toLong)

  for (i <- 0 to x.length - 1) {
    val max = Math.max(x(i) - x.head, x.last - x(i))
    val min = Math.min(x(i) - x.lift(i - 1).getOrElse(Long.MaxValue), x.lift(i + 1).getOrElse(Long.MaxValue) - x(i))
    println(min + " " + max)
  }
}

object A extends App {
 val n = readLine.toInt
 val str = readLine
 val arr = str.split(" ").map(_.toInt)
 val mn = arr(0)
 val mx = arr(n - 1)

 import scala.math._

 print(arr(1) - arr(0))
 print(" ")
 println(mx - arr(0))

 for(i <- (1 until n - 1)) {
    print(max(abs(arr(i) - arr(i-1)), abs(arr(i + 1) - arr(i))))
    print(" ")
    println(
            max(
                abs(arr(i) - mn),
                abs(mx - arr(i))
               )
           )
 }

 print(mx - arr(n - 2))
 print(" ")
 println(mx - mn)
}


object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(x1, y1, x2, y2) = scala.io.StdIn.readLine().split(" ").map(_.toLong)

    val ans = (x2 - x1) * (y2 - y1) + 1

    println(ans)
  }
}

import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val arr = readIntLine()
      println(calcWays(arr(2) - arr.head, arr.last - arr(1)))
    }
    //      println(calcWays(4, 5))
  }

  def calcWays(x: Int, y: Int): Long = x.toLong * y + 1

  def makeArray(n: Int) {
    class QueueElement(val left: Int, val right: Int) {}

    val arr = Array.ofDim[Int](n)
    val intervals = (0 to n).map(_ => ListBuffer[QueueElement]()).toArray
    intervals(n) += new QueueElement(0, n - 1)
    var count = 1
    for (i <- (0 to n).reverse) {
      var intOfLengthI = intervals(i)
      intOfLengthI = intOfLengthI.sortBy(_.left)
      for (j <- intOfLengthI.indices) {
        val head = intOfLengthI(j)
        if (head.left == head.right) {
          arr(head.left) = count
        } else {
          val mid = (head.left + head.right) / 2
          arr(mid) = count
          if (mid != head.left) intervals(mid - head.left) += new QueueElement(head.left, mid - 1)
          intervals(head.right - mid) += new QueueElement(mid + 1, head.right)
        }
        count += 1
      }
    }

    printArray(arr)
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val arr = readIntLine()
      println(calcWays(arr(2) - arr.head, arr.last - arr(1)))
    }
//      println(calcWays(4, 5))
  }

  def calcWays(x: Int, y: Int):  BigInt = {
    if (x < 0 || y < 0) 0
    if (x == 0 || y == 0) 1 else {
      val i = Math.max(x + 1, y + 1)
      val j = Math.min(x + 1, y + 1)

      def sum(list: List[BigInt], acc: BigInt, listAcc: List[BigInt]): List[BigInt] = list match {
        case Nil => listAcc.reverse
        case s :: ss => sum(ss, acc + s, (acc + s) :: listAcc)
      }

      def helper(prev: List[BigInt], j: Int): BigInt = if (j == 1) prev.last
      else helper(sum(prev, 0, Nil), j - 1)

      helper((1 to i).map(_ => BigInt(1)).toList, j)
    }
  }

  def makeArray(n: Int) {
    class QueueElement(val left: Int, val right: Int) {}

    val arr = Array.ofDim[Int](n)
    val intervals = (0 to n).map(_ => ListBuffer[QueueElement]()).toArray
    intervals(n) += new QueueElement(0, n - 1)
    var count = 1
    for (i <- (0 to n).reverse) {
      var intOfLengthI = intervals(i)
      intOfLengthI = intOfLengthI.sortBy(_.left)
      for (j <- intOfLengthI.indices) {
        val head = intOfLengthI(j)
        if (head.left == head.right) {
          arr(head.left) = count
        } else {
          val mid = (head.left + head.right) / 2
          arr(mid) = count
          if (mid != head.left) intervals(mid - head.left) += new QueueElement(head.left, mid - 1)
          intervals(head.right - mid) += new QueueElement(mid + 1, head.right)
        }
        count += 1
      }
    }

    printArray(arr)
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val arr = readIntLine()
      println(calcWays(arr(2) - arr.head, arr.last - arr(1)))
    }
//      println(calcWays(1, 2))
  }

  def calcWays(x: Int, y: Int):  BigInt = {
    if (x == 0 || y == 0) 1 else {
      val i = Math.max(x + 1, y + 1)
      val j = Math.min(x + 1, y + 1)

      def sum(list: List[BigInt], acc: BigInt, listAcc: List[BigInt]): List[BigInt] = list match {
        case Nil => listAcc.reverse
        case s :: ss => sum(ss, acc + s, (acc + s) :: listAcc)
      }

      def helper(prev: List[BigInt], j: Int): BigInt = if (j == 1) prev.last
      else helper(sum(prev, 0, Nil), j - 1)

      helper((1 to i).map(_ => BigInt(1)).toList, j)
    }
  }

  def makeArray(n: Int) {
    class QueueElement(val left: Int, val right: Int) {}

    val arr = Array.ofDim[Int](n)
    val intervals = (0 to n).map(_ => ListBuffer[QueueElement]()).toArray
    intervals(n) += new QueueElement(0, n - 1)
    var count = 1
    for (i <- (0 to n).reverse) {
      var intOfLengthI = intervals(i)
      intOfLengthI = intOfLengthI.sortBy(_.left)
      for (j <- intOfLengthI.indices) {
        val head = intOfLengthI(j)
        if (head.left == head.right) {
          arr(head.left) = count
        } else {
          val mid = (head.left + head.right) / 2
          arr(mid) = count
          if (mid != head.left) intervals(mid - head.left) += new QueueElement(head.left, mid - 1)
          intervals(head.right - mid) += new QueueElement(mid + 1, head.right)
        }
        count += 1
      }
    }

    printArray(arr)
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val arr = readIntLine()
      println(calcWays(arr(2) - arr.head, arr.last - arr(1)))
    }
//      println(calcWays(4, 5))
  }

  def calcWays(x: Int, y: Int):  BigInt = {
    if (x < 0 || y < 0) 0
    else if (x == 0 || y == 0) 1 else {
      val i = Math.max(x + 1, y + 1)
      val j = Math.min(x + 1, y + 1)

      def sum(list: List[BigInt], acc: BigInt, listAcc: List[BigInt]): List[BigInt] = list match {
        case Nil => listAcc.reverse
        case s :: ss => sum(ss, acc + s, (acc + s) :: listAcc)
      }

      def helper(prev: List[BigInt], j: Int): BigInt = if (j == 1) prev.last
      else helper(sum(prev, 0, Nil), j - 1)

      helper((1 to i).map(_ => BigInt(1)).toList, j)
    }
  }

  def makeArray(n: Int) {
    class QueueElement(val left: Int, val right: Int) {}

    val arr = Array.ofDim[Int](n)
    val intervals = (0 to n).map(_ => ListBuffer[QueueElement]()).toArray
    intervals(n) += new QueueElement(0, n - 1)
    var count = 1
    for (i <- (0 to n).reverse) {
      var intOfLengthI = intervals(i)
      intOfLengthI = intOfLengthI.sortBy(_.left)
      for (j <- intOfLengthI.indices) {
        val head = intOfLengthI(j)
        if (head.left == head.right) {
          arr(head.left) = count
        } else {
          val mid = (head.left + head.right) / 2
          arr(mid) = count
          if (mid != head.left) intervals(mid - head.left) += new QueueElement(head.left, mid - 1)
          intervals(head.right - mid) += new QueueElement(mid + 1, head.right)
        }
        count += 1
      }
    }

    printArray(arr)
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

}

object C extends App {
  private def gazGiz(x: Long, y: Long): Long =
    x + (x + y - 1) * (x + y - 2) / 2

  private def binomial(n: Int, k: Int): Long =
    if (k > n - k) binomial(n, n - k)
    else (1 to k).foldLeft(1L)((b, i) => b * (n - k + i) / i)

  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(x1, y1, x2, y2) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val r = y2 - y1
    val d = x2 - x1 + y2 - y1

    val ans = binomial(d, r)

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(x1, y1, x2, y2) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val ans = (x2 - x1) * (y2 - y1) + 1

    println(ans)
  }
}


object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n = (h-t)/(2 *t-h-c)
        val (n1, n2) = (n, n+1)
        val d1 = (n1*c+(n1+1)*h)-t*(2*n1+1)
        val d2 = t*(2*n2+1)-(n2*c+(n2+1)*h)
        val res = if (d1*(2*n2+1) > d2*(2*n1+1)) 2*n2+1 else 2*n1+1
        println(res)
      }
    }
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2 * t

    val ans =
      if (d >= 0) 2
      else if (h <= t) 1
      else if (c >= t) 2
      else { // c < t < h
        val k  = (t - h) / d.toDouble
        val ks = List(k.ceil, k.floor).sorted.sortBy(k => math.abs((h - t + k * d) / (1.0 + 2 * k)))

        (1 + 2 * ks.head).toInt
      }

    println(ans)
  }
}

//package codeforces.contests._1359

object _3 {

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      println {
        if (t >= h) 1
        else if (t <= (h + c) / 2.0) 2
        else {
          def nearest(y: Long): BigDecimal = (BigDecimal((y + 1) * h + y * c) / BigDecimal(2.0 * y + 1) - BigDecimal(t)).abs

          def solve(y: Long): (BigDecimal, Long) = (nearest(y), 2 * y + 1)

          val y = (t - h) / (h + c - 2 * t)

          val ls = List(solve(y - 1), solve(y), solve(y + 1))

          val min = ls.minBy(_._1)._1

          ls.filter(_._1 == min).minBy(_._2)._2
        }
      }
    }
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2 * t

    val ans =
      if (d >= 0) 2
      else if (h <= t) 1
      else if (c >= t) 2
      else { // c < t < h
        val k  = (t - h) / d.toDouble
        val ks = List(k.floor, k.ceil).sortBy(k => math.abs((h - t + k * d) / (1.0 + 2 * k)))

        (1 + 2 * ks.head).toInt
      }

    println(ans)
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  // 999977 17 499998
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val second = (abs((h + c) - 2 * t).toDouble, 2L)

      def nearest(y: Long): Long = abs(((y + 1) * h + y * c) - (y + 1 + y) * t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.ceil.toLong
      }

      val third = solve(y)

      val ls = List(second, third)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  // 999977 17 499998
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val second = (abs((h + c) - 2 * t).toDouble, 2L)

      def nearest(y: Long): Long = abs(((y + 1) * h + y * c) - (y + 1 + y) * t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val (df, dfy) = solve(y)
      val (dc, dcy) = solve(y + 1)

      val odd = if(df >= dc) (dc, dcy) else (df, dfy)

      val ls = List(second, odd)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val first = (abs(h - t).toDouble, 1L)
      val second = (abs((h + c) - 2 * t).toDouble, 2L)

      def nearest(y: Long): Double = abs(((y + 1) * h + y * c) * 1.0 / (y + 1 + y) - t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val third = solve(y)
      val fourth = solve(y + 1)

      val ls = List(first, second, third, fourth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  // 999977 17 499998
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val second = (abs((h + c) - 2 * t).toDouble, 2L)

      def nearest(y: Long): Long = abs(((y + 1) * h + y * c) - (y + 1 + y) * t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.round
      }

      val third = solve(y)

      val ls = List(second, third)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  // 999977 17 499998
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val second = (abs((h + c) - 2 * t).toDouble, 2L)

      def nearest(y: Long): Double = abs(((y + 1) * h + y * c) * 1.0 / (y + 1 + y) - t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val (df, dfy) = solve(y)
      val (dc, dcy) = solve(y + 1)

      val odd = if (df >= dc) (dc, dcy) else (df, dfy)

      val ls = List(second, odd)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val first = (abs(h - t).toDouble, 1L)
      val second = (abs((h + c) / 2 - t).toDouble, 2L)

      val y = {
        val temp = (t - h) * 1.0 / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      def nearest(y: Long): Double = ((y + 1) * h + y * c) * 1.0 / (y + 1 + y)

      val third: (Double, Long) = (abs(nearest(y) - t), 2 * y + 1)

      val fourth = (abs(nearest(y + 1) - t), 2 * (y + 1) + 1)

      val fifth = {
        val ty = (y - 1) max 0
        (abs(nearest(ty) - t), 2 * ty + 1)
      }

      val ls = List(first, second, third, fourth, fifth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val first = (abs(h - t).toDouble, 1L)
      val second = (abs((h + c) / 2 - t).toDouble, 2L)

      def nearest(y: Long): Double = abs(((y + 1) * h + y * c) * 1.0 / (y + 1 + y) - t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val third = solve(y)
      val fourth = solve(y + 1)

      val ls = List(first, second, third, fourth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val first = (abs(h - t).toDouble, 1L)
      val second = (abs((h + c) - 2*t).toDouble, 2L)

      def nearest(y: Long): Long = abs(((y + 1) * h + y * c) - (y + 1 + y) * t)

      def solve(y: Long): (Double, Long) = (nearest(y), 2 * y + 1)

      val y = {
        val temp = ((t - h) * 1.0) / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val third: (Double, Long) = solve((y - 1) max 0)
      val fourth = solve(y)
      val fifth = solve(y + 1)
      val sixth = solve(y + 2)
      val seventh = solve(y + 3)
      val eigth = solve((y - 2) max 0)

      val ls = List(first, second, third, fourth, fifth, sixth, seventh, eigth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toInt)

      val first = (abs(h - t).toDouble, 1)
      val second = (abs((h + c) / 2 - t).toDouble, 2)

      val y = {
        val temp = (t - h) * 1.0 / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toInt
      }

      def nearest(y: Int): Double = ((y + 1) * h + y * c) * 1.0 / (y + 1 + y)

      val third = (abs(nearest(y) - t), 2*y+1)

      val fourth = (abs(nearest(y + 1) - t), 2*(y+1) + 1)

      val ls = List(first, second, third, fourth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

//package codeforces.contests._1359

object _3 {

  import math._

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(h, c, t) = io.StdIn.readLine.split(" ").map(_.toLong)

      val first = (abs(h - t).toDouble, 1L)
      val second = (abs((h + c) / 2 - t).toDouble, 2L)

      def nearest(y: Long): Double = ((y + 1) * h + y * c) * 1.0 / (y + 1 + y)

      def solve(y: Long): (Double, Long) = (abs(nearest(y) - t), 2 * y + 1)

      val y = {
        val temp = (t - h) * 1.0 / (h + c - 2 * t)
        if (temp < 0) 0 else temp.floor.toLong
      }

      val third: (Double, Long) = solve((y - 1) max 0)
      val fourth = solve(y)
      val fifth = solve(y + 1)
      val sixth = solve(y + 2)
      val seventh = solve(y + 3)
      val eigth = solve((y - 2) max 0)

      val ls = List(first, second, third, fourth, fifth, sixth, seventh, eigth)

      val min = ls.minBy(_._1)._1

      println {
        ls.filter(_._1 == min).minBy(_._2)._2
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      require(t <= h && t >= c)
      if (4*t >= 3*h+c) println(1)
      else if (2*t >= h+c) println(2)
      else {
        val dn = (t-c)/(2.0*t-h-c)
        val n1 = dn.toDouble.toInt
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1)
        val c1 = (ft(n1)-t).abs
        val c2 = (ft(n2)-t).abs
        if (c1 < c2) println(n1*2-1) else println(n2*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        def ft(n: Int) = (((n*h)+(n-1)*c)/(2.0*n-1) - t).abs

        val ress = (n1 to n1 + 2).map(ft)
        val res = ress.indexOf(ress.min) + n1
        println((res*2-1) max 1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      require(t <= h && t >= c)
      if (4*t >= 3*h+c) println(1)
      else if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1) - t
        val c1 = ft(n1).abs
        val c2 = ft(n2).abs
        val res = if ((t-c) % (2*t-h-c) == 0 || c1 <= c2) (n1*2-1) else (n2*2-1)
        println(res max 1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        def ft(n: Long) = ((((n.toLong*h)+(n-1)*c)/(2.0*n-1)) - t).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println(res*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))

      if (2*t <= h +c) println(2)
      else {
        val n1 = (h-t)/(2 *t-h-c)
        def ft(n: Long) = ((n*h+n*c-c)- t*(2*n+1)).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println(res*2+1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))

      if (2*t <= h +c) println(2)
      else {
        val n1 = (h-t)/(2 *t-h-c)
        val n2 = n1 + 1

        val f1 = n1*c+(n1+1)*h-(2*n1+1)*t
        val f2 = 2*(n2+1)*t-n2*c-(n2+1)*h
        val res =
          if (f1 <= f2) n1 else n2
        println(res*2+1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      require(t <= h && t >= c)
      if (4*t >= 3*h+c) println(1)
      else if (2*t <= h+c) println(2)
      else {
        val dn = (t-c)/(2.0*t-h-c)
        val n1 = dn.toDouble.toInt
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1)
        val c1 = (ft(n1)-t).abs
        val c2 = (ft(n2)-t).abs
        if (c1 < c2) println(n1*2-1) else println(n2*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        def ft(n: Int) = (((n*h)+(n-1)*c)/(2.0*n-1) - t).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println((res*2-1) max 1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1: Long = (t-c)/(2 *t-h-c)
        def ft(n: Long) = ((((n.toLong*h)+(n-1L)*c)/(2.0*n-1)) - t).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println(res*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))

      if (2*t <= h +c) println(2)
      else {
        val n1 = (h-t)/(2 *t-h-c)
        val n2 = n1 + 1

        val f1 = n1*c+(n1+1)*h-(2*n1+1)*t
        val f2 = 2*(n2+1)*t-n1*c-(n1+1)*h
        val res =
          if (f1 <= f2) n1 else n2
        println(res*2+1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        def ft(n: Int) = (BigDecimal(((n*h)+(n-1)*c)/(2.0*n-1)) - t).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println(res*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toLong)
      val (h, c, t) = (input(0), input(1), input(2))

      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        def ft(n: Long) = ((n*h+n*c+h)- t*(2*n+1)).abs
        val f1 = ft(n1)
        val f2 = ft(n1+1)
        val res = if (f1<=f2) n1 else n1+1
        println(res*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (t >= h) println(1)
      else if (2*t <= h+c) println(2)
      else {
        val dn = (t-c)/(2.0*t-h-c)
        val n1 = dn.toDouble.toInt
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1)
        val c1 = (ft(n1)-t).abs
        val c2 = (ft(n2)-t).abs
        if (c1 < c2) println(n1*2-1) else println(n2*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      require(t <= h && t >= c)
      if (4*t >= 3*h+c) println(1)
      else if (2*t <= h +c) println(2)
      else {
        val dn = (t-c)/(2.0*t-h-c)
        val n1 = dn.toDouble.toInt
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1)
        val c1 = (ft(n1)-t).abs
        val c2 = (ft(n2)-t).abs
        if ((t-c) % (2*t-h-c) == 0 || c1 <= c2) println(n1*2-1) else println(n2*2-1)
      }
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (h, c, t) = (input(0), input(1), input(2))
      if (2*t <= h +c) println(2)
      else {
        val n1 = (t-c)/(2 *t-h-c)
        val n2 = n1 + 1
        def ft(n: Int) = ((n*h)+(n-1)*c)/(2.0*n-1) - t
        val c1 = ft(n1).abs
        val c2 = ft(n2).abs
        val res = if ((t-c) % (2*t-h-c) == 0 || c1 <= c2) (n1*2-1) else (n2*2-1)
        println(res max 1)
      }
    }
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else 2 * math.ceil((t - h) / d).toInt + 1

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else {
        val r = math.ceil(2 * (t - h) / d + 1).toInt

        if (r == 0) 2
        else r
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else {
        val k = (t - h) / d

        val ks = List(0, 0.5, k.ceil, k.floor)
          .filter(_ >= 0)
          .sortBy(k => math.abs(h - t + k * (c + h - 2 * t)) / (2 * k + 1.0))

        2 * ks.head.toInt + 1
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else if (h <= t) 1
      else {
        val r = math.ceil(2 * (t - h) / d + 1).toInt
        if (r <= 0) 2 else r
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    def diff(k: Double): Double = math.abs((h - t + k * d) / (2 * k + 1))

    val ans =
      if (d == 0) 2
      else {
        val k = (t - h) / d

        if (k < 0) List(1.0, 2.0).sortBy(diff).head.toInt
        else List(k.ceil, k.floor).sortBy(diff).map(2 * _ + 1).head.toInt
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2 * t

    val ans =
      if (d >= 0) 2
      else if (h <= t) 1
      else if (c >= t) 2
      else { // c < t < h
        val k  = (t - h) / d.toDouble
        val ks = List(k.ceil, k.floor).sortBy(k => math.abs((h - t + k * d) / (1.0 + 2 * k)))

//        println()
//        println(s"(c + h / 2) ? t = ${c + h - 2 * t}")
//        println(s"ks: ${ks.mkString(", ")}")

        (1 + 2 * ks.head).toInt
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else {
        val r = math.ceil(2 * (t - h) / d + 1).toInt

        if (r <= 0) 2
        else r
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    val ans =
      if (d == 0) 2
      else {
        val k = (t - h) / d

        val ks = List(0.5, k.ceil, k.floor)
          .filter(_ >= 0)
          .sortBy(k => math.abs(h - t + k * (c + h - 2 * t)) / (2 * k + 1.0))

        (2 * ks.head + 1).toInt
      }

    println(ans)
  }
}

object C extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(h, c, t) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

    val d = c + h - 2.0 * t

    def diff(k: Double): Double = math.abs((h - t + k * d) / (2 * k + 1))

    val ans =
      if (d == 0) 2
      else {
        val k = (t - h) / d

        if (k < 0) List(1.0, 2.0).sortBy(k => diff((k - 1) / 2)).head.toInt
        else List(k.ceil, k.floor).sortBy(diff).map(2 * _ + 1).head.toInt
      }

    println(ans)
  }
}


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[this] val oj = System.getenv("ATCODER_DEBUG") == null
  @inline private final def DEBUG(f: => Unit): Unit = {
    if (!oj){ f }
  }
  @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) }
  @inline private final def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) }
  @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) }
  @inline private final def debugDim(m: Array[Array[Int]]): Unit = if (!oj){
    REP(m.length) { i =>
      debug(m(i))
    }
  }
  @inline private final 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()
    }
  }
  @inline private final def debug(s: => String): Unit = DEBUG {
    System.err.println(s)
  }
  @inline private final def debugL(num: => Long): Unit = DEBUG {
    System.err.println(num)
  }
  private def isDebug[A](debug: => A, online: => A): A = {
    if (oj) online else debug
  }

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

    @inline private[this] final 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)(f)
  }
  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
  }
}

object Workspace {
  import Main._
}

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
  import Workspace._

  // toIntとか+7とかするならvalにしろ
  final private[this] val MOD = 1000000007

  def solve(): Unit = {
    REP(ni()) { _ =>
      val n, x = ni()
      out.println(x * 2)
    }
  }
}

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
  def solve(): Unit = {
    val n = ni()
    val A = na(2*n)
    var i = 1;
    while(i < 2*n){
    	var a = A(i)
		println(2*A(i))
    	i += 2;
    }

  }
}

import Array._
import scala.collection.mutable.ListBuffer

/**
1 2 3 4 5 6 7 8 9 10 11 12
  2 3 4 5 6 7 8 9 10 11 12
  2   4 5 6 7 8 9 10 11 12
  2   4   6 7 8 9 10 11 12
  2   4   6   8 9 10 11 12
  2   4   6   8   10 11 12
  2   4   6   8   10    12
**/

object Main {
    def main(args: Array[String]) {
        val in = new java.util.Scanner(System.in)
        val lineNumber = in.next().toInt
        for ( i <- 0 until lineNumber ) {
            val n = in.next().toInt
            val x = in.next().toInt
            println(x*2)
        }
    }
}


import scala.collection._

object B extends App {

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

  val n = readInt
  val xSet = mutable.BitSet.empty ++ readInts(n)

  val S = 1000000

  val res = mutable.ArrayBuffer[Int]()
  var debt = 0

  for (x <- 1 to S / 2) {
    val y = S - x + 1
    if (xSet(x) && !xSet(y)) {
      res += y
      xSet += y
    } else if (!xSet(x) && xSet(y)) {
      res += x
      xSet += x
    } else if (xSet(x) && xSet(y)) {
      debt += 1
    }
  }

  for (x <- 1 to S / 2) {
    val y = S - x + 1
    if (debt > 0 && !xSet(x) && !xSet(y)) {
      res += y
      res += x
      debt -= 1
    }
  }

  println(res.size)
  println(res.mkString(" "))
}

import scala.collection._

object B extends App {

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

  val n = readInt
  val xSet = mutable.BitSet.empty ++ readInts(n)

  val S = 1000000

  val res = mutable.ArrayBuffer[Int]()
  var debt = 0

  for (x <- 1 to S / 2) {
    val y = S - x + 1
    if (xSet(x) && !xSet(y)) res += y
    else if (!xSet(x) && xSet(y)) res += x
    else if (xSet(x) && xSet(y)) debt += 1
  }

  for (x <- 1 to S / 2) {
    val y = S - x + 1
    if (debt > 0 && !xSet(x) && !xSet(y)) {
      res += x
	  res += y
      debt -= 1
    }
  }

  println(res.size)
  println(res.mkString(" "))
}

/**
 * I've tried to make this piece of code as readable as possible.
 * Enjoy hacking it!
 */
import scala.collection._

object B extends App {

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

  val n = readInt
  val xs = readInts(n)
  var xSum = 0L
  for (x <- xs) xSum += x
  xSum -= n

  val xSet = mutable.BitSet.empty ++ xs

  val S = 1000000

  val res = mutable.ArrayBuffer[Int]()
  val used = mutable.BitSet.empty

  for (x <- 1 to S if ! used(x)) {
    val sy = S - x + 1
    if (!xSet(sy)) {
      res += sy
      xSet += sy
    } else {

    }
  }

  println(res.size)
  println(res.mkString(" "))
}