//package codeforces.contests._1407

object Ahahahahahahahaha {
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {

      val n = io.StdIn.readInt()
      val seq = io.StdIn.readLine.split(" ").map(_.toInt)

      val ones = seq.count(_ == 1)

      if (ones <= n / 2) {
        println(s"${n / 2}\n${(1 to n/2).map(_ => 0).mkString(" ")}")
      } else {
        val req = if ((n / 2) % 2 == 0) n / 2 else n / 2 + 1
        println(s"$req\n${(1 to req).map(_ => 1).mkString(" ")}")
      }
    }
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val m  = n / 2
    val an = readLine()

    val zeros = an.count(_ == '0')

    if (zeros >= m) {
      println(m)
      println("0 " * m)
    } else {
      // format: off
      println(m + m % 2)
      println("1 " * (m + m % 2))
    }
  }
}

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */

import scala.io.StdIn._

object Main {
  def f(ayes: Array[Int]): Array[Int] = {
    val n = ayes.length
    val cnt1 = ayes.count(x => x == 1)
    val cnt0 = n - cnt1

    val res = if (cnt1 <= n / 2)
      for (_ <- 0 until cnt0) yield 0
    else
      for (_ <- 0 until (cnt1 - cnt1 % 2)) yield 1

     res.toArray
  }

  def main(args: Array[String]): Unit = {
    // Write your solution here
    val t = readInt

    for (_ <- 0 until t) {
      val _ = readInt
      val ayes = readLine.split(" ").map(_.toInt)
      val result = f(ayes)
      println(result.length)
      println(result.mkString(" "))
    }
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val m  = n / 2
    val an = readLine()

    val (ones, zeros) = (an.count(_ == '1'), an.count(_ == '0'))

    if (zeros >= m) {
      println(m)
      println("0 " * m)
    } else if (m % 2 == 0) {
      println(m)
      println("1 " * m)
    } else {
      println(m + 1)
      println("1 " * (m + 1))
    }
  }
}

//package codeforces.contests._1407

object Ahahahahahahahaha {
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {

      val n = io.StdIn.readInt()
      val seq = io.StdIn.readLine.split(" ").map(_.toInt)

      val ones = seq.count(_ == 1)

      if (ones <= n / 2) {
        println(s"${n / 2}\n${(1 to n/2).map(_ => 0).mkString(" ")}")
      } else {
        val req = if ((n / 2) % 2 == 0) n / 2 else n / 2 + 1
        println(s"${n / 2}\n${(1 to req).map(_ => 1).mkString(" ")}")
      }
    }
  }
}

/**
* Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
*/

import scala.io.StdIn._

object Main {
   def isAha(ayes: Array[Int]): Boolean = {
      val n = ayes.length

      if (n == 1) {
         ayes(0) == 0
      } else {
         val flippedOthers = for ((a, i) <- ayes.zipWithIndex) yield
            if (i % 2 == 0) a else -a
         flippedOthers.sum == 0
      }
   }

   def f(n: Int, ayes: Array[Int]): Array[Int] = {
      if (n == 2) {
         if (isAha(ayes.slice(0, 1))) ayes.slice(0, 1)
         else ayes.slice(1, 2)
      } else if (isAha(ayes)){
         ayes
      } else {
         ayes.slice(2, n)
      }
   }

   def main(args: Array[String]): Unit = {
      // Write your solution here
      val t = readInt

      for (_ <- 0 until t) {
         val n = readInt
         val ayes = readLine.split(" ").map(_.toInt)
         val result = f(n, ayes)
         println(result.length)
         println(result.mkString(" "))
      }
   }
}

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */

import scala.io.StdIn._

object Main {
  def f(ayes: Array[Int]): Array[Int] = {
    val n = ayes.length
    val cnt1 = ayes.count(x => x == 1)
    val cnt0 = n - cnt1

    val res = if (cnt1 <= n / 2)
      for (_ <- 0 until cnt0) yield 0
    else
      for (_ <- 0 until (cnt1 - cnt1 % 2)) yield 0

     res.toArray
  }

  def main(args: Array[String]): Unit = {
    // Write your solution here
    val t = readInt

    for (_ <- 0 until t) {
      val _ = readInt
      val ayes = readLine.split(" ").map(_.toInt)
      val result = f(ayes)
      println(result.length)
      println(result.mkString(" "))
    }
  }
}

/**
* Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
*/

import scala.io.StdIn._

object Main {
   def f(n: Int, ayes: Array[Int]): Array[Int] = {
      Array(0)
   }

   def main(args: Array[String]): Unit = {
      // Write your solution here
      val t = readInt

      for (_ <- 0 until t) {
         val n = readInt
         val ayes = readLine.split(" ").map(_.toInt)
         val result = f(n, ayes)
         println(result.length)
         println(result.mkString(" "))
      }
   }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val an = readLine()

    val (ones, zeros) = (an.count(_ == '1'), an.count(_ == '0'))

    if (n == 2) {
      if (zeros > 0) println("1\n0")
      else println("2\n1 1")
    } else {
      if (ones > zeros) println(s"${n / 2}\n${"1 " * (n / 2)}")
      else println(s"${n / 2}\n${"0 " * (n / 2)}")
    }
  }
}

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

  val t = readInt()

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

    val (ones, zeros) = (an.count(_ == 1), an.count(_ == 0))

    val base = if (ones > zeros) 1 else 0
    val ans = an
      .foldLeft((List.empty[Int], n / 2)) {
        case ((bs, 0), a) => (a :: bs, 0)
        case ((bs, r), a) => if (a == base) (bs, r - 1) else (a :: bs, r)
      }
      ._1
      .reverse

    println(n / 2)
    println(ans.mkString(" "))
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val an = readLine()

    val (ones, zeros) = (an.count(_ == '1'), an.count(_ == '0'))

    val ans = (if (ones > zeros) "1 " else "0 ") * (n / 2)

    println(n / 2)
    println(ans.trim)
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val an = readLine()

    val (ones, zeros) = (an.count(_ == '1'), an.count(_ == '0'))

    val ans = (if (ones > zeros) "1 " else "0 ") * (n / 2)

    println(n / 2)
    println(ans)
  }
}

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

  val t = readInt()

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

    val (ones, zeros) = (an.count(_ == 1), an.count(_ == 0))

    val ans =
      if (ones > zeros) List.fill(n / 2)(1)
      else List.fill(n / 2)(0)

    println(n / 2)
    println(ans.mkString(" "))
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val n  = readInt()
    val m  = n / 2
    val an = readLine()

    val (ones, zeros) = (an.count(_ == '1'), an.count(_ == '0'))

    if (zeros > m) {
      println(m)
      println("0 " * m)
    } else if (m % 2 == 0) {
      println(m)
      println("1 " * m)
    } else {
      println(m + 1)
      println("1 " * (m + 1))
    }
  }
}

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

  val t = readInt()

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

    val (ones, zeros) = (an.count(_ == 1), an.count(_ == 0))

    val ans =
      if (ones == n) List.fill(n)(1)
      else if (ones > zeros) List.fill(n / 2)(1)
      else List.fill(n / 2)(0)

    println(n / 2)
    println(ans.mkString(" "))
  }
}


object C1183 {

  import IO._
  import collection.{mutable => cu}
  import scala.collection.mutable.ArrayBuffer

  def main(args: Array[String]): Unit = {
    var q = readInt
    while (q > 0) {
      val Array(k, n, a, b) = readLongs(4)
      var res = -1L
      var s = 0L
      var e = math.min(n, k / a)
      while (s <= e) {
        val mid = (e + s) / 2
        if (k > (mid * a) + ((n - mid) * b)) {
          res = mid
          s = mid + 1
        } else {
          e = mid - 1
        }
      }
      out.println(res)
      q -= 1
    }
    out.close()
  }

  object IO {
    private val input = new java.io.BufferedReader(
      new java.io.InputStreamReader(
        if (System.getProperty("ONLINE_JUDGE") != null) System.in
        else new java.io.FileInputStream("src/input")
      )
    )
    val out = new java.io.PrintWriter(System.out)

    @inline def read: String = input.readLine()

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

    def readInt: Int = tokenizeLine.nextToken.toInt

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

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

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

}

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

  override def apply(io: IO): io.type = {
    val queries = io.read[Seq[(Long, Long, Long, Long)]]

    val ans = queries map { case (k, n, a, b) =>
      val x = ((k - b*n)/(1.0 * (a - b))).ceil.toLong - 1
      (x max - 1) min n
    }

    io.writeLines(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[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")

  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 writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = "\n")
  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: 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
      }
    }
  }
}


import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine.toInt
    val a = (0 until n).map(_ => StdIn.readLine)
    val b = a.sortWith((x, y) => x.length < y.length)
    val result = !(1 until n).exists(i => !b(i).contains(b(i-1)))
    if (result) {
      println("YES")
      b.foreach(println(_))
    } else {
      println("NO")
    }
  }
}

object problemA {
    import java.io.{BufferedReader, FileInputStream, InputStreamReader}
    import scala.collection.mutable.ArrayBuffer
    import scala.collection.mutable
    import scala.util.control.Breaks._
    import scala.collection.JavaConverters._

    val source = System.in
    implicit val reader = new BufferedReader(new InputStreamReader(source))

    def read()(implicit reader: BufferedReader): String = reader.readLine().split(" ")(0)
    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(" ")
    def readString()(implicit reader: BufferedReader): String = reader.readLine()

    def main(args: Array[String]): Unit = {
        val Array(n) = readArray().map(_.toInt)
        var a = new Array[String](n)
        for (i <- 0 until n) a(i) = readString()

        a = a.sortWith((p1, p2) => p1.length < p2.length)
        for (i <- 0 until n - 1) {
            if (!a(i + 1).contains(a(i))) {
                print("NO")
                return
            }
        }

        println("YES")
        a.foreach(println(_))
    }
}

/**
  * @author ShankarShastri
  *         Algorithm: CF_486_DIV3_B (http://codeforces.com/contest/988/problem/B)
  */

import scala.io.StdIn._
import scala.annotation.tailrec

object CF_486_DIV3_B {

  @tailrec
  def subStringVerifier(list: List[String]): Boolean = {
    if(list.length == 0 || list.length == 1) true
    else if(list.length == 2) {
        if(list.last.contains(list.head)) true
        else false
      } else {
      list match {
        case head :: tail if tail.head.contains(head)=> subStringVerifier(tail)
        case _ => false
      }
    }
  }

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

    val list = (1 to n).map{ _ =>
      readLine
    }.toList
    val createdList = list.sortBy(_.length)
    if(subStringVerifier(createdList)) {
      println("YES")
      createdList.map(println)
    } else {
      println("NO")
    }
  }
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, p) = in.next().split(' ').map(_.toInt)
  val str = in.next()
  if (n == 1) {
    val candidate = (str.head + 1).toChar
    if (candidate - 'a' >= p)
      println("NO")
    else
      println(candidate)
  } else if (n == 2) {
    println((str.last + 1 until ('a' + p)).find(i => i != str.head) match {
      case Some(x) => str.head.toString + x
      case None if str.head + 1 < 'a' + p => (str.head + 1).toChar.toString + 'a'
      case None => "NO"
    })
  } else {
    println(str.indices.reverse.find{
      case (index) =>
        (str(index) + 1 until ('a' + p)).exists(i => index == 0 ||
          (str(index - 1) != i && (index == 1 || str(index - 2) != i)))
    } match {
      case None => "NO"
      case Some(index) =>
        val l = (str(index) + 1 until ('a' + p)).find(i => index == 0 ||
          (str(index - 1) != i && (index == 1 || str(index - 2) != i))).map(_.toChar).get
        val prefix = l :: str.toCharArray.take(index).toList.reverse
        (index + 1 until n).foldLeft(prefix) {
          case (pref, i) => ('a' to ('a' + p).toChar).find(i => !pref.take(2).contains(i)).get :: pref
        }.reverse.mkString
    })
  }

}

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

/**
 * Created by arseny on 07.09.14.
 */
object C extends App {
  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextLong = in.nextLong
  def nextDouble = in.nextDouble
  def nextString = in.next

  def solve() = {
    val n = nextInt
    val p = nextInt
    val s = nextString
    val as = "qwertyuiopasdfghjklzxcvbnm".sorted.take(p)
    if(p == 1) {
      out.print("NO")
    } else {
      def getCandidates(s: String, start: Char) = s.length match {
        case 0 => as.dropWhile(_ < start)
        case 1 => as.dropWhile(_ < start).filterNot(c => c == s(0))
        case n => as.dropWhile(_ < start).filterNot(c => c == s(n - 1) || c == s(n - 2))
      }
      def tryFill(s: String, start: Char, size: Int): (String, Boolean) = {
        if(size == 0) {
          (s, true)
        } else {
          val cs = getCandidates(s, start)
          if(cs.isEmpty) {
            ("", false)
          } else {
            var found = false
            var res = ("", false)
            for(i <- 0 until cs.length if(!found)) {
              val trySuffix = tryFill(s + cs(i), 'a', size - 1)
              if(trySuffix._2 == true) {
                found = true
                res = trySuffix
              }
            }
            res
          }
        }
      }
      var found = false
      var res = ("NO", false)
      for(i <- n - 2 to -1 by(-1) if(!found)) {
        val start = (s(i + 1).toInt + 1).toChar
        val trySuffix = tryFill(s.take(i + 1), start, n - i - 1)
        if(trySuffix._2 == true) {
          found = true
          res = trySuffix
        }
      }
      out.print(res._1)
    }
  }

  try {
    solve()
  } catch {
    case _: Exception => sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, p) = in.next().split(' ').map(_.toInt)
  val str = in.next()
  if (n == 1) {
    val candidate = (str.head + 1).toChar
    if (candidate - 'a' >= p)
      println("NO")
    else
      println(candidate)
  } else if (n == 2) {
    println((str.last + 1 until ('a' + p)).find(i => i != str.head) match {
      case Some(x) => str.head.toString + x
      case None if str.head + 1 < 'a' + p => (str.head + 1).toChar.toString + 'a'
      case None => "NO"
    })
  } else {
    println(str.reverse.sliding(3).zipWithIndex.find{
      case (str, index) =>
        (str.head + 1 until ('a' + p)).exists(i => i != str(1) && i != str(2))
    } match {
      case None => "NO"
      case Some((_, index)) =>
        val l = (str(index) + 1 until ('a' + p)).find(i => i != str(1) && i != str(2)).map(_.toChar).get
        val prefix = l :: str.toCharArray.take(n - index - 1).toList.reverse
        (0 until index).foldLeft(prefix) {
          case (pref, i) => ('a' to ('a' + p).toChar).find(i => !pref.take(2).contains(i)).get :: pref
        }.reverse.mkString
    })
  }

}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, p) = in.next().split(' ').map(_.toInt)
  val str = in.next()
  if (n == 1) {
    val candidate = (str.head + 1).toChar
    if (candidate - 'a' >= p)
      println("NO")
    else
      println(candidate)
  } else if (n == 2) {
    println((str.last + 1 until ('a' + p)).find(i => i != str.head) match {
      case Some(x) => str.head.toString + x
      case None if str.head + 1 < 'a' + p => (str.head + 1).toChar.toString + 'a'
      case None => "NO"
    })
  } else {
    println(str.indices.reverse.find{
      case (index) =>
        (str(index) + 1 until ('a' + p)).exists(i => index == 0 ||
          ((str(index - 1) != i) && (index == 1 || str(index - 2) != i)))
    } match {
      case None => "NO"
      case Some(index) =>
        val l = (str(index) + 1 until ('a' + p)).find(i => index == 0 ||
          ((index == 1 || str(index - 1) != i) && (index == 2 || str(index - 2) != i))).map(_.toChar).get
        val prefix = l :: str.toCharArray.take(index).toList.reverse
        (index + 1 until n).foldLeft(prefix) {
          case (pref, i) => ('a' to ('a' + p).toChar).find(i => !pref.take(2).contains(i)).get :: pref
        }.reverse.mkString
    })
  }

}


import scala.io.StdIn
import scala.util.control.Breaks

object Main extends App{

    val k = StdIn.readLine.toInt
    for (i <- 0 until k) {
        val n = StdIn.readLine.toInt
        val arr = StdIn.readLine.split(" ").map(_.toInt).sorted(Ordering.Int.reverse)

        var res = 0
        var key = true
        var j = 0
        while (key && j < n) {
            if ( j < arr(j) )
                res += 1
            else
                key = false
            j += 1
        }

//        arr.foreach(it => print(s"$it "))
        println(res)
    }

}

object A {
  def main(args: Array[String]): Unit = {
    val k = scala.io.StdIn.readInt()
    val result = for (i <- 1 to k) yield {
      val test = new A
      test.solution
    }
    println(result.mkString("\n"))
  }
}

class A {

  def solution(): Int = {
    val n = scala.io.StdIn.readInt()
    val numbers = scala.io.StdIn.readLine().split(" ")
    val planks = for (number <- numbers) yield number.toInt
    maxSquare(planks.sortWith(_ < _), 0)
  }

  private def maxSquare(planks: Array[Int], i: Int): Int = {
    if (i >= planks.length) 0
    else (planks.length - i).min(planks(i)).max(maxSquare(planks, i + 1))
  }

}

import java.util.ArrayList
import java.util.StringTokenizer
//import scala.reflect.io.File
import java.io.BufferedReader
import java.io.BufferedInputStream
import java.io.InputStreamReader
import java.io.ByteArrayInputStream
import java.io.InputStream

object CF_599_A {   var br = createBufferedReader(); var debugV = false

    //COMMENT ME !
    //runTest(Test.sa1)
    //debugV = true
//    runFromFile("""C:\work\git\ap-codeforces\Codeforces\src\fb\aprokh\fb2018r2\jacks_candy_shop_2.txt""")

  def main(args: Array[String]): Unit = {
    //---------------------------- parameters reading
    val k = readLine.int

    for(i <- 1 to k) {
      val n = readLine.int
      val planks = new Array[Int](n)
      val lp = readLine
      for (p <- 0 until n) {
        planks(p) = lp.int
      }

      val st = planks.sorted.reverse
      var res = 0
      var min = st(0)
      for(p <- 0 until st.size) {
        if (st(p) < min) min = st(p)
        if (min >= (p+1)) res = p+1
      }
      outLn(res)
    }

//    debug("n = " + n)

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

    debug("================= RESULT ================== ")
    finish
  }

  //============================ service code ======================

//  var file:File = null
  val resultStr = new StringBuilder
  def outLn(str:String) = resultStr.append(str).append("\n")
  def outLn(number:Long) = resultStr.append(number+"").append("\n")
  def finish() {
//    if (file == null || !devEnv) {
      println(resultStr.toString())
      Console.flush()
//    } else {
//      file.writeAll(resultStr.toString())
//    }
  }

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

  def createBufferedReader(inst:InputStream = System.in): BufferedReader = {
    val bis = if (inst == null) new BufferedInputStream(System.in) else new BufferedInputStream(inst);
    new BufferedReader(new InputStreamReader(bis));
  }

  def runTest(str:String) = if (devEnv) {
    br = createBufferedReader(new ByteArrayInputStream(str.trim.getBytes("ISO-8859-1")))
  }

//  def runFromFile(fileName: String) = if (devEnv) {
//    br = createBufferedReader(new FileInputStream(fileName))
//  }

  def debug(x: => String) = if (debugV && devEnv) println(x) // nullary function

  lazy val devEnv = this.getClass.getCanonicalName.contains(".")

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

val sa1 = """
4
5
4 3 1 4 5
4
4 4 4 4
3
1 1 1
5
5 5 1 1 5
"""

val sa2 = """
101
"""

val sa3 = """
10100
"""
 }
}

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

  override def solve(io: IO) = io.repeat {
    val plans = io.read[Vector[Int]].sorted(desc[Int])

    val ans = plans.zipWithIndex map {
      case (l, i) => l min (i + 1)
    }

    io.write(ans.max)
  }
}
/****************************[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 = {printer.print(obj); this}
  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 = write(obj mkString separator)
  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
      }
    }
  }
}


/**
  * @author ShankarShastri
  *         Algorithm: CF_485_DIV_2_1 (http://codeforces.com/contest/987/problem/A)
  */

//package programming

import scala.io.StdIn._
import scala.annotation.tailrec

object CF_485_DIV_2_1 {

//  the Power Gem of purple color,
//  the Time Gem of green color,
//  the Space Gem of blue color,
//  the Soul Gem of orange color,
//  the Reality Gem of red color,
//  the Mind Gem of yellow color.

  def main(args: Array[String]): Unit = {
    val n = readInt
    val thanosMap = Map[String, String](("purple", "Power"), ("green", "Time"), ("blue", "Space"),
      ("orange", "Soul"), ("red", "Reality"), ("yellow","Mind"))
    if(n == 0) {
      println(thanosMap.size)
      thanosMap.values.map(println(_))
    } else {
      val mapResult = (0 until n).foldLeft(thanosMap)((a,b) => {
        val k = readLine
        a - k
      })
      println(mapResult.size)
      mapResult.values.map(println(_))
    }
  }
}

import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val dist = Map("purple" -> "Power", "green" -> "Time", "blue" -> "Space",
      "orange" -> "Soul", "red" -> "Reality", "yellow" -> "Mind")
    val m = StdIn.readLine.toInt
    val noNeed = (0 until m).map(_ => StdIn.readLine).map(dist(_))
    val all = dist.values
    val need = all.map(item => if (noNeed.contains(item)) None else Some(item))
    println(need.count(_.isDefined))
    need.foreach(_.foreach(println(_)))
  }
}

object tanya extends App{
var a = readInt
var sum = 7
val stones = scala.collection.mutable.Map("purple" -> "Power", "green" -> "Time", "blue" -> "Space", "orange" -> "Soul", "red" -> "Reality", "yellow" -> "Mind")

for(i <- 0 to a){
    val stone = readLine
    stones -= stone
    sum = sum - 1
}
println(sum)
stones.values.map(println(_))
}

object A extends App {
  val l = List(
    "purple" -> "Power",
    "green" -> "Time",
    "blue" -> "Space",
    "orange" -> "Soul",
    "red" -> "Reality",
    "yellow" -> "Mind"
  )

  val n = scala.io.StdIn.readInt()
  val cs = (0 until n).foldLeft(List.empty[String])((cs, _) => scala.io.StdIn.readLine() :: cs)

  val m = l.foldLeft(List.empty[String]) { case (rs, (c, r)) =>
      if (cs.contains(c)) rs
      else r :: rs
  }

  println(m.length)
  println(m.mkString("\n"))
}

/**
  * @author ShankarShastri
  *         Algorithm: CF_485_DIV_2_1 (http://codeforces.com/contest/987/problem/A)
  */

//package programming

import scala.io.StdIn._
import scala.annotation.tailrec

object CF_485_DIV_2_1 {

//  the Power Gem of purple color,
//  the Time Gem of green color,
//  the Space Gem of blue color,
//  the Soul Gem of orange color,
//  the Reality Gem of red color,
//  the Mind Gem of yellow color.

  def main(args: Array[String]): Unit = {
    val n = readInt
    val thanosMap = Map[String, String](("purple", "Power"), ("green", "Time"), ("blue", "Space"),
      ("orange", "Soul"), ("red", "Reality"), ("yellow","Mind"))
    if(n == 0) {
      println(thanosMap.size)
      thanosMap.values.map(println(_))
    } else {
      val mapResult = (0 until n).foldLeft(thanosMap)((a,b) => {
        val k = readLine
        println(a - k)
        a - k
      })
      println(mapResult.size)
      mapResult.values.map(println(_))
    }
  }
}


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

  val t = readInt()

  (0 until t).foreach { _ =>
    val s = readLine()

    def definitely(pf: PartialFunction[(Char, Int), Int]): Seq[Int] = s.zipWithIndex.collect(pf)

    val first =
      definitely {
        case ('0' | '?', i) if i % 2 == 1 => i
        case ('1' | '?', i) if i % 2 == 0 => i
      } applyOrElse (5, (_: Int) => 9)

    val second =
      definitely {
        case ('0' | '?', i) if i % 2 == 0 => i
        case ('1' | '?', i) if i % 2 == 1 => i
      } applyOrElse (5, (_: Int) => 9)

    val answer = (first min second) + 1

    println(answer)
  }
}

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

  val t = readInt()

  (0 until t).foreach { _ =>
    val s = readLine()

    val a = s.zipWithIndex.collect {
      case ('0' | '?', i) if i % 2 == 1 => i
      case ('1' | '?', i) if i % 2 == 0 => i
    }
    val b = s.zipWithIndex.collect {
      case ('0' | '?', i) if i % 2 == 0 => i
      case ('1' | '?', i) if i % 2 == 1 => i
    }

    val ans = (a.applyOrElse(5, (_: Int) => 9) min b.applyOrElse(5, (_: Int) => 9)) + 1

    println(ans)
  }
}


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

  val t = readInt()

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

    val t1 = (x2 - x1).abs
    val t2 = (y2 - y1).abs

    val ans = t1 + t2 + (if (t1 == 0 || t2 == 0) 0 else 2)

    println(ans)
  }
}

object A {
  import InOut._
  def main(args: Array[String]): Unit = {

    for (_ <- 1 to nextInt) {
      val x1, y1, x2, y2 = nextLong
      val dx = Math.abs(x1 - x2)
      val dy = Math.abs(y1 - y2)
      val n = if (dx == 0) dy
      else if (dy == 0) dx
      else dx + dy + 2

      out.println(n)
    }

    out.flush()
  }

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


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

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

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

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

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

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

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

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

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

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

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

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

  def solve(): Unit = {
    REP(ni()) { _ =>
      val N, X = ni()
      var lastBlow, eachHit = -1e9.toInt
      REP(N) { _ =>
        val d, h = ni()
        lastBlow = max(d, lastBlow)
        eachHit = max(eachHit, d - h)
      }
      debug(s"lastBlow:$lastBlow eachHit:$eachHit")
      if (eachHit <= 0 && X > lastBlow) out.println(-1)
      else {
        val remain = X - lastBlow
        if (remain > 0) {
          val ans = (remain + eachHit - 1) / eachHit + 1
          out.println(ans)
        } else {
          out.println(1)
        }
      }
    }
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val input = new Scanner(System.in);
    val t = input.nextInt()
    for (_ <- 0 until t) {
      val n = input.nextInt()
      val x = input.nextInt()
      val d = new Array[Int](n)
      val h = new Array[Int](n)

      for (i <- 0 until n) {
        d(i) = input.nextInt()
        h(i) = input.nextInt()
      }
      var max = Int.MinValue;
      for (i <- 0 until n) {
        max = Math.max(max, d(i))
      }
      var max2 = Int.MinValue;
      for (i <- 0 until n) {
        max2 = Math.max(max2, d(i) - h(i))
      }
      var ans = 0
      if(max >= x){
        ans = 1
      }else /* max < x */{
        if(max2 <= 0){
          ans = -1;
        }else{
          val rem = x - max;
          ans = 1
          ans += (rem + max2 -1)/max2
        }
      }

      System.out.println(ans)

    }
  }
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer

  import scala.io.Codec
  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 B {

  def main(args: Array[String]): Unit = {}
  @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)) }

  val Array(t) = readInts(1)

  for (_ <- 1 to t) {
    val Array(n, x) = readInts(2)
    val blows = Array.fill(n) {
      readLongs(2)
    }
    val maxD = blows.map(_.head).max
    val maxKill = blows.map(b => b(0) - b(1)).max
    val rem = x - maxD
    val res = if (rem <= 0) 1 else if (maxKill <= 0) -1 else 1 + (rem + maxKill - 1) / maxKill
    println(res)
  }
}

import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  val t = readInt()
  for (_ ← 0 until t) {
    val Array(n, x) = readLine.trim.split(' ').map(_.toInt)
    val blows = Array.fill(n){
      val Array(d, h) = readLine.trim.split(' ').map(_.toInt)
      Blow(d, h)
    }
    val fatal = blows.maxBy{_.damage}.damage
    if (x > fatal) {
      blows.filter(b ⇒ b.damage > b.heal) match {
        case e if e.nonEmpty ⇒
          val efficient = e.maxBy(_.pureDamage)
          println((x - fatal + efficient.pureDamage - 1) / efficient.pureDamage + 1)
        case _ ⇒ println(-1)
      }
    }else {
      println(1)
    }
  }
}
case class Blow(damage: Long, heal: Long) {
  def pureDamage: Long = damage - heal
}


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

  (0 until t).foreach { _ =>
    val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val s           = scala.io.StdIn.readLine().sorted

    val (a, b)   = s.splitAt(k)
    val (ah, al) = (a.head.toString, a.last.toString)

    val ans =
      if (ah != al || b.isEmpty) al
      else {
        val (bh, bl) = (b.head.toString, b.last.toString)

        ah + (if (bh != bl) b else bh * ((n - 1) / k))
      }

    println(ans)
  }
}

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

  (0 until t).foreach { _ =>
    val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val s           = scala.io.StdIn.readLine().sorted

    val ans =
      if (s(0) != s(k - 1) || k == n) s(k - 1).toString
      else if (s(k) != s(n - 1)) s(0).toString + s.slice(k, n)
      else s(0) + s(k).toString * ((n - 1) / k)

    println(ans)
  }
}

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

  (0 until t).foreach { _ =>
    val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val s           = scala.io.StdIn.readLine().sorted

    def lexical(str: String, pref: String = ""): String =
      if (str.isEmpty) pref
      else {
        val (l, r) = str.splitAt(k)

        lexical(r, pref + l.last)
      }

    val ans = lexical(s)

    println(ans)
  }
}


//package solutions

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

import scala.collection.mutable

/**
  * @author traff
  */

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

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

    out.close()
  }

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

    val n = s.nextInt()
    val k = s.nextInt()

    val a = new Array[Int](n)
    val b = new Array[Int](n)

    for (i <- a.indices) {
      a(i) = s.nextInt()
    }

    for (i <- b.indices) {
      b(i) = s.nextInt()
    }

    val d = a.zip(b).map(d => d._1 - d._2).zipWithIndex.sortWith((a, b) => a._1 < b._1)

    var res = 0
    d.take(k).foreach(t => {
      res += a(t._2)
      b(t._2) = Integer.MAX_VALUE
      a(t._2) = 0
    })

    res += a.zip(b).foldLeft(0)((s, b) => s + math.min(b._1, b._2))

    out.println(res)

  }

}

import java.util.Scanner

/**
  * Created by huangdongfa on 17/3/7.
  */
object App {
    def main(args: Array[String]) {
        val scanner = new Scanner(System.in)
        val n = scanner.nextInt
        val k = scanner.nextInt
        val a = new Array[Int](n)
        val b = new Array[Int](n)
        for (i <- a.indices) a(i) = scanner.nextInt
        for (j <- b.indices) b(j) = scanner.nextInt

        val sum = a.zip(b).sortWith((a, b) => a._1 - a._2 < b._1 - b._2).zipWithIndex.foldLeft(0) {(s, c) => {
            if (c._2 < k || c._1._1 - c._1._2 < 0) {
                s + c._1._1
            }
            else {
                s + c._1._2
            }
        }}
        System.out.println(sum)
    }
}


import scala.io.Source

object CF338A {
    def main(args: Array[String]) {
        val r = Source.stdin.bufferedReader()
        var ss = r.readLine().split(" ")
        val n = ss(0).toInt
        val m = ss(1).toInt
        val b = new Array[Boolean](m)
        for (i <- 0 until n) {
            ss = r.readLine().split(" ")
            val k = ss(0).toInt
            for (j <- 1 until k + 1) {
                val index = ss(j).toInt
                b(index - 1) = true
            }
        }
        var result = "YES"
        for (i <- 0 until m) {
            if (!b(i)) {
                result = "NO"
            }
        }
        println(result)
    }
}

/*
import java.io.FileInputStream
import java.io.PrintStream
import java.io.FileOutputStream
*/

object bulbs{
  val MAX_M = 105

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

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

    val Array(n, m) = readLine.split(" ").map(_.toInt)
    var open = Array.fill[Boolean](MAX_M)(false)
    for(i <- 1 to n) {
      val (Array(nb), bulbs) = readLine.split(" ").map(_.toInt).splitAt(1)
      for(j <- 0 until nb) {
        open(bulbs(j)) = true
      }
    }

    var close_all = "YES"
    for(i <- 1 to m) {
      if(!open(i)) {
        close_all = "NO"
      }
    }
    println(close_all)
  }
}

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

object Main {
  def main(args: Array[String]) {
    val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)
    val s = new mutable.BitSet()
    for (i <- 0 until n) {
      StdIn.readLine().split(" ").map(_.toInt - 1).drop(1).foreach(s.add(_))
    }
    println(if (s.size == m) "YES" else "NO")
  }
}

import scala.collection.mutable.ArrayBuffer

object Main extends App {
    val arr = Console.in.readLine().split(' ')
    val n = arr(0).toInt
    val q = arr(1).toInt
    val bulbsState = new Array[Boolean](q)
    for(i <- 0 until n){
      val arr = Console.in.readLine().split(' ')
      val c = arr(0).toInt
      for(j <- 1 to c){
        bulbsState(arr(j).toInt - 1) = true
      }
    }
    var flag = true
    for(b <- bulbsState if b == false) flag = false
    println(if(flag) "YES" else "NO")
}

import scala.collection.immutable.HashSet
import scala.io.StdIn

/**
  * Created by shvedchikov on 13.01.16.
  */
object Codeforces extends App {
    override def main(args: Array[String]) {
        lamps()
    }

    // http://codeforces.com/problemset/problem/615/A
    def lamps(): Unit = {
        val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)
        (1 to n)
            .map(_ => StdIn.readLine().split(" ").map(_.toInt))
            .foldLeft(HashSet.empty[Int])((all, cur) => all ++ (cur match {
                case Array(xi: Int, rest @_*) if rest.length.equals(xi) => rest
                case _ => Seq.empty[Int]
            })).size match {
            case `m` => print("YES")
            case _ => print("NO")
        }
    }
}

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

/**
  * Created by hsleep on 2016. 1. 8..
  */
object ASolution extends App {
  val Array(numOfButtons, numberOfBulbs) = StdIn.readLine().split(' ').map(_.toInt)

  val setOfBulbs: mutable.Set[Int] = mutable.Set[Int]()
  for {
    i <- 0 until numOfButtons
    if setOfBulbs.size != numberOfBulbs
  } {
    setOfBulbs ++= StdIn.readLine().split(' ').map(_.toInt).tail
  }

  setOfBulbs.size == numberOfBulbs match {
    case true => println("YES")
    case _ => println("NO")
  }
}

import scala.collection._

object A extends App {

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

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

  val lamps = mutable.Set.empty[Int]

  for (_ <- 1 to n) {
    lamps ++= readLine.split(" ").map(_.toInt).drop(1)
  }

  println(if (lamps.size == m) "YES" else "NO")
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val Array(n, m) = in.next().split(' ').map(_.toInt)
  val lamps = Array.ofDim[Boolean](m)
  (1 to n).foreach { _ =>
    in.next().split(' ').map(_.toInt - 1).tail.foreach(j => lamps(j) = true)
  }
  if (lamps.forall(_ == true))
    println("YES")
  else
    println("NO")
}

object A615 {
  @inline def read = scala.io.StdIn.readLine

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

  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, m) = readInts(2)
    val isOn = Array.fill(m)(false)
    for(i <- 0 until n) {
      val tl = tokenizeLine
      val number = tl.nextToken.toInt
      val input = Array.fill(number)(tl.nextToken.toInt)
      for(j <- input.indices) {
        isOn(input(j)-1) = true
      }
    }

    println(if(isOn.forall(identity)) "YES" else "NO")
  }
}

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

object _615A extends CodeForcesApp {
  override type Result = Boolean

  override def solve(scanner: Scanner) = {
    import scanner._
    val (n, m) = (nextInt(), nextInt())
    val bulbs = ((1 to n) flatMap {i =>
      Seq.fill(nextInt())(nextInt())
    }).toSet
    (1 to m) forall bulbs.contains
  }

  override def format(result: Boolean) = if (result) "YES" else "NO"
}
/****************************[Ignore Template Below]****************************************/
abstract class CodeForcesApp {
  val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  val mod: Int = 1000000007
  type Result
  def solve(scanner: Scanner): Result
  def format(result: Result): String = result.toString
  def apply(scanner: Scanner): String = format(solve(scanner))
  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
/*********************************[Scala Scanner]*******************************************/
import java.io._
import java.nio.file.{Files, Path}
import java.util.StringTokenizer

import scala.io.Codec

/**
 * Scala implementation of a faster java.util.Scanner
 * See: http://codeforces.com/blog/entry/21125
 * All next methods throw NoSuchElementException when !hasNext
 */
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))

  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)

  private[this] val tokenizers = lines.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
    lines.next()
  }
  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()
}

import java.util.Scanner

/**
  * Author: Svyatoslav Ilinskiy
  * Date: 08.01.16.
  */
object Problem1 {

  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val numButtons = sc.nextInt()
    val numBulbs = sc.nextInt()
    val bulbs = new Array[Boolean](numBulbs)
    (0 until numButtons).foreach { _ =>
      val numBulbsByThisButton = sc.nextInt()
      (0 until numBulbsByThisButton).foreach { _ =>
        bulbs.update(sc.nextInt() - 1, true)
      }
    }
    val res =
      if (bulbs.forall(b => b)) "YES"
      else "NO"
    println(res)
  }

}

import java.util.Scanner

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

    var bulb = new Array[Boolean](m+1)
    for(i <- 1 to n){
      val x = sc.nextInt()
      for(j <- 1 to x){
        val tmp = sc.nextInt()
        bulb(tmp) = true
      }
    }

    var flag = true
    for(i <- 1 to m)
      flag &= bulb(i)

    if(flag)
      println("YES")
    else
      println("NO")
  }
}

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

/**
  * Created by hsleep on 2016. 1. 8..
  */
object ASolution extends App {
  val Array(numOfButtons, numberOfBulbs) = StdIn.readLine().split(' ').map(_.toInt)

  val setOfBulbs: mutable.Set[Int] = mutable.Set[Int]()
  for {
    i <- 0 until numOfButtons
    if setOfBulbs.size != numberOfBulbs
  } {
    setOfBulbs ++= StdIn.readLine().split(' ').map(_.toInt)
  }

  setOfBulbs.size == numberOfBulbs match {
    case true => println("YES")
    case _ => println("NO")
  }
}

import java.util.Scanner

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

    var bulb = new Array[Boolean](m+1)
    for(i <- 1 to n){
      val x = sc.nextLine().split(' ').map(_.toInt)

      for(e <- x)
        bulb(e) = true
    }

    var flag = true
    for(i <- 1 to m)
      flag &= bulb(i)

    if(flag)
      println("YES")
    else
      println("NO")
  }
}

import java.util.Scanner

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

    var bulb = new Array[Boolean](m+1)
    for(i <- 1 to n){
      try{
        val x = sc.nextLine().split(' ').map(_.toInt)
        for(e <- x)
          bulb(e) = true
      }
      catch{
        case e: NumberFormatException => ()
      }
    }

    var flag = true
    for(i <- 1 to m)
      flag &= bulb(i)

    if(flag)
      println("YES")
    else
      println("NO")
  }
}


import io.StdIn.readLine

object testing {
  def main(args: Array[String]): Unit = {
      val T = readLine().toInt
      for(_ <- 1 to T) {
        val N = readLine().toLong
        if((N & (N-1)) == 0){
          println("NO")
        }else{
          println("YES")
        }
      }
  }
}

object Main {

  def main(args: Array[String]): Unit = {
    import io.StdIn.readLine

    val t = readLine().toInt
    for (_ <- 1 to t) {
      val n = readLine().toLong
      val answer =
        if ((n & (n - 1)) == 0)
          "NO"
        else
          "YES"
      println(answer)
    }
  }

}


object B extends App {

  @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)) }

  val s = readLine

  var res = 0L
  var w = 0L
  var wo = 0L

  for (i <- 1 until s.length) {
    if (s(i) == 'v' && s(i - 1) == 'v') {
      res += wo
      w += 1
    } else if (s(i) == 'o') {
      wo += w
    }
  }

  println(res)
}

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

  override def apply(io: IO): io.type = {
    val s = io.read[String]
      .replace("ovo", "oo")
      .replace("ov", "o,v")
      .replace("vo", "v,o")
      .split(",")
      .view
      .map(t => if (t.startsWith("v")) ('w', t.length - 1) else ('o', t.length))

    @tailrec
    def solve(i: Int, wc: Long, owc: Long, wowc: Long): Long = {
      if (i < 0) {
        wowc
      } else {
        s(i) match {
          case ('w', w) => solve(i - 1, wc = wc + w, owc = owc       , wowc = wowc + w*owc)
          case ('o', o) => solve(i - 1, wc = wc    , owc = owc + o*wc, wowc = wowc)
          case _ => throw new IllegalStateException()
        }
      }
    }

    val ans = solve(i = s.length - 1, wc = 0, owc = 0, wowc = 0)
    io.write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[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")

  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 writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = "\n")
  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: 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 {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

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

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

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

  def solve(): Unit = {
    val N, K = ni()
    var cur, next = Array.ofDim[Long](4, 2001) // 0: BB, 1: BW, 2: WB, 3:WW
    cur(0)(1) = 1
    cur(1)(2) = 1
    cur(2)(2) = 1
    cur(3)(1) = 1

    rep(N - 1) { x =>
      rep(4) { i =>
        rep(4) { j =>
          rep(x * 2 + 3) { k =>
            val pls =
              if (i == 1 || i == 2) {
                // BW
                // WB
                if (i == 1 && j == 2 || i == 2 && j == 1) 2
                // BB
                // WB
                else 0
              } else {
                // Ww
                // WB
                if (i != j) 1
                // Ww
                // WW
                else 0
              }

            if (k + pls <= 2000) next(j)(k + pls) = (next(j)(k + pls) + cur(i)(k)) % MOD
          }
        }
      }

      val t = cur
      cur = next
      next = t
      rep(4)(i => java.util.Arrays.fill(next(i), 0))
    }

    val ans = cur.map(_(K)).sum
    out.println(ans % MOD)
  }

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

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

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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

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

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

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

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

  def solve(): Unit = {
    val N, K = ni()
    var cur, next = Array.ofDim[Long](4, 2001) // 0: BB, 1: BW, 2: WB, 3:WW
    cur(0)(1) = 1
    cur(1)(2) = 1
    cur(2)(2) = 1
    cur(3)(1) = 1

    rep(N - 1) { _ =>
      rep(4) { i =>
        rep(4) { j =>
          rep(2001) { k =>
            val pls =
              if (i == 1 || i == 2) {
                // BW
                // WB
                if (i == 1 && j == 2 || i == 2 && j == 1) 2
                // BB
                // WB
                else 0
              } else {
                // Ww
                // WB
                if (i != j) 1
                // Ww
                // WW
                else 0
              }

            if (k + pls <= 2000) next(j)(k + pls) = (next(j)(k + pls) + cur(i)(k)) % MOD
          }
        }
      }

      val t = cur
      cur = next
      next = t
      rep(4)(i => java.util.Arrays.fill(next(i), 0))
    }

    val ans = cur.map(_(K)).sum
    out.println(ans % MOD)
  }

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

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

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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


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

import scala.util.Sorting

/**
  * @author Arthur Gazizov (Cinarra Systems)
  *         Created on 24.06.17.
  */
object Main {
  def main(args: Array[String]): Unit = {
    var out: PrintWriter = null
    var in: CodeforcesReader = null
    out = new PrintWriter(new OutputStreamWriter(System.out))
    in = new CodeforcesReaderWithStringTokenizerImpl(new BufferedReader(new InputStreamReader(System.in)))
    IOUtils.init(in)
    val solver = new Solver()
    solver.solve(1, in, out)
    in.close()
    out.close()
  }

  class Solver {
    def calculateSum(cost: Array[Long], m: Int): Long = {
      var tmp = cost.clone()
      for (i <- cost.indices) {
        tmp(i) += (i + 1L) * m
      }
      Sorting.quickSort(tmp)
      var sum = 0L
      for (i <- 0 until m) {
        sum += tmp(i)
      }
      sum
    }

    def f(cost: Array[Long], m: Int, have: Long): Boolean = {
      calculateSum(cost, m) <= have
    }

    def solve(testNumber: Int, in: CodeforcesReader, out: PrintWriter): Unit = {
      val n = in.nextInt()
      val have = in.nextLong()
      val cost = IOUtils.nextLongArray(n)
      var hi = n
      var lo = 0
      while (hi - lo > 3) {
        var m = (hi + lo) / 2
        if (!f(cost, m, have)) {
          hi = m
        } else {
          lo = m
        }
      }
      while (lo < n && f(cost, lo + 1, have)) {
        lo += 1
      }
      out.print(lo + " " + calculateSum(cost, lo))
    }
  }

  class CodeforcesReaderWithStringTokenizerImpl(reader: BufferedReader) extends CodeforcesReader {
    private var tokenizer: StringTokenizer = _

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

    override def nextInt(): Int = {
      next().toInt
    }

    override def nextLong(): Long = {
      next().toLong
    }

    override def nextDouble(): Double = {
      next().toDouble
    }
    override def close(): Unit = {
      tokenizer = null
      reader.close()
    }
  }

  abstract class CodeforcesReader() extends Closeable {
    def next(): String

    def nextInt(): Int

    def nextLong(): Long

    def nextDouble(): Double
  }

  object IOUtils {
    private var in: CodeforcesReader = _

    def init(codeforcesReader: CodeforcesReader): Unit = {
      this.in = codeforcesReader
    }

    def nextIntArray(size: Int): Array[Int] = {
      val ret = new Array[Int](size)
      for (i <- ret.indices) {
        ret(i) = in.nextInt()
      }
      ret
    }

    def nextLongArray(size: Int): Array[Long] = {
      val ret = new Array[Long](size)
      for (i <- ret.indices) {
        ret(i) = in.nextLong()
      }
      ret
    }

    def nextDoubleArray(size: Int): Array[Double] = {
      val ret = new Array[Double](size)
      for (i <- ret.indices) {
        ret(i) = in.nextDouble()
      }
      ret
    }

    def nextStringArray(size: Int): Array[String] = {
      val ret = new Array[String](size)
      for (i <- ret.indices) {
        ret(i) = in.next()
      }
      ret
    }
  }

}


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

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

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

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

  def solve(): Unit = {
    val t = ni()
    rep(t) { _ =>
      val s, a, b, c = nl()
      val d = s / c
      val ans = (d / a) * b + d
      out.println(ans)
    }
  }

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

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

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(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 map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

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

object CF1065A extends App {

  val t = readInt()

  (1 to t) foreach(n => {
    val Array(s, a, b, c) = readLine().split(" ").map(_.toLong)

    var count = s/c + ((s/c)/a)*b

    println(count)

  })
}


import scala.collection.mutable

object A extends App {
  def readInts = readLine().split(" ").map(_.toInt)

  val Array(n, a, b) = readInts
  val s = readLine

  val c1 = s(a-1)
  val c2 = s(b-1)

  if (c1 == c2) println("0") else println("1")
}

import scala.io.StdIn.readLine

object A extends App {

  val Array(n, a, b) = readLine.split("\\s+").map(_.toInt - 1)

  val airports = readLine.map(e => if (e == '0') 0 else 1)

  val sameAirport = airports(a) == airports(b)

  val result = if (sameAirport) 0 else 1

  println(result)

}

object A743 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    var Array(n,a,b) = readInts(3)
    a -= 1
    b -= 1
    val in = read
    if(in(a) == in(b))
      println("0")
    else
      println("1")
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

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

    def readInt: Int = tokenizeLine.nextToken.toInt

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

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

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

}

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

object _743A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write, writeAll, writeLine}
    val n, a, b = read[Int]
    val airports = read[String]
    val start = airports(a - 1)
    val end = airports(b - 1)

    val ans = if (start == end) 0 else 1

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

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

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

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

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

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

  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 = "\n"): 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 java.util.ArrayList
import java.util.StringTokenizer
//import scala.reflect.io.File
import java.io.BufferedReader
import java.io.BufferedInputStream
import java.io.InputStreamReader
import java.io.ByteArrayInputStream
import java.io.InputStream

object A_384 {   var br = createBufferedReader(); var debugV = false

    //COMMENT ME !
    runTest(Test.sa2)
    debugV = true
//    file = File("C:\\temp\\google cj\\2014q\\c-small.res")

  def main(args: Array[String]): Unit = {
    //---------------------------- parameters reading
    val line1 = readLine
    val n = line1.int
    val a = line1.int
    val b = line1.int

    val line2 = readLine.string

    val res = if (line2(a-1) == line2(b-1)) 0 else 1

    outLn(res)
    finish
  }

  //============================ service code ======================

//  var file:File = null
  val resultStr = new StringBuilder
  def outLn(str:String) = resultStr.append(str).append("\n")
  def outLn(number:Integer) = resultStr.append(number+"").append("\n")
  def finish() {
//    if (file == null || !devEnv) {
      println(resultStr.toString())
//    } else {
//      file.writeAll(resultStr.toString())
//    }
  }

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

  def createBufferedReader(inst:InputStream = System.in): BufferedReader = {
    val bis = if (inst == null) new BufferedInputStream(System.in) else new BufferedInputStream(inst);
    new BufferedReader(new InputStreamReader(bis));
  }

  def runTest(str:String) = if (devEnv) {
    br = createBufferedReader(new ByteArrayInputStream(str.trim.getBytes("ISO-8859-1")))
  }

  def debug(x: => String) = if (debugV && devEnv) println(x) // nullary function

  lazy val devEnv = this.getClass.getCanonicalName.contains(".")

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

val sa1 = """
4 1 4
1010
"""

val sa2 = """
5 5 2
10110
"""

val sa3 = """
"""
}

}

import scala.io.StdIn.readLine

object A  extends App{

  val Array(n: Int, a: Int, b: Int) = readLine().split("\\s+").map(_.toInt - 1)

//  val airports = readLine.map(_.toInt)
  val airports = readLine.map(e => if ( e == '0') 0 else 1)

//  println(s"n $n  a: $a   b: $b")
//  println(airports.mkString(","))

  val sameAirport = airports(a) == airports(b)
//  println(s"sameAriport: $sameAirport")

  if (sameAirport)
    println(0)
  else {
    val start = a min b
    val stop = a max b
//    println(s"start: $start, stop: $stop")

    val trip = (airports.drop(start)).dropRight(n - stop)
//   println(trip.mkString(","))

    val c1 = trip.head
    val c2 = trip.last
    val cost1 = trip.indexOf(c2)
    val cost2 = trip.reverse.indexOf(c1)
    println( cost1 min cost2)
  }
}

import scala.io.StdIn.readLine

object A  extends App{

  val Array(n: Int, a: Int, b: Int) = readLine().split("\\s+").map(_.toInt - 1)

  val airports = readLine.map(_.toInt)

//  println(s"n $n  a: $a   b: $b")
//  println(airports.mkString(","))

  val sameAirport = airports(a) == airports(b)
//  println(s"sameAriport: $sameAirport")

  if (sameAirport)
    println(0)
  else {
    val start = a min b
    val stop = a max b
//    println(s"start: $start, stop: $stop")

    val trip = airports.drop(start).dropRight(n + 1 - stop)
//    println(trip.mkString(","))

    val c1 = trip.head
    val c2 = trip.last
    val cost1 = trip.indexOf(c2)
    val cost2 = trip.reverse.indexOf(c1)
    println( cost1 min cost2)
  }
}

import scala.io.StdIn.readLine

object A  extends App{

  val Array(n: Int, a: Int, b: Int) = readLine().split("\\s+").map(_.toInt - 1)

  val airports = readLine.map(_.toInt)

  val sameAirport = airports(a) == airports(b)

  if (sameAirport)
    println(0)
  else {
    val start = a min b
    val stop = a max b
    val trip = airports.drop(start).dropRight(n - stop)
    val c1 = trip.head
    val c2 = trip.last
    val cost1 = trip.indexOf(c2)
    val cost2 = trip.reverse.indexOf(c1)
    println( cost1 min cost2)
  }
}


object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  val x = line.count(_ == 'x')
  val y = line.length - x

  println("x" * (x - y) + "y" * (y - x))
}

object Main {
  def main(args: Array[String]) {
    val s = readLine()
    val xs = s.count(_ == 'x')
    val ys = s.count(_ == 'y')

    println("x" * (xs - ys) + "y" * (ys - xs))
  }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()
  println(line.replaceAll("yx", "").replaceAll("xy", ""))
}