object A {

  def main(args: Array[String]): Unit = {
    (new A).solve()
  }

}

class A {
  val out = new java.io.PrintWriter(System.out)
  val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
  def tokenizer = new java.util.StringTokenizer(in.readLine)
  def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }
  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 solve() = {
    val Array(t) = readInts(1)

    REP(t) { _ =>
      val Array(str, int, exp) = readLongs(3)

      def can(i: Long) = {
        str + i > int + (exp - i)
      }

      @annotation.tailrec
      def binSearch(low: Long, hi: Long): Long = {
        if (hi < low) low
        else {
          val mid = (low + hi) / 2
          if (can(mid)) binSearch(low, mid - 1)
          else binSearch(mid + 1, hi)
        }
      }

      val res = exp - binSearch(0, exp) + 1

      out.println(res)
    }

    out.flush()
  }
}

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

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

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

}

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

  import math.{max, min}

  def solve(): Unit = {
    val t = ni()
    for (_ <- 1 to t) {
      var str, int, exp = ni()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

object A {

  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(str, int, exp) = readLongs(3)

    def can(i: Long) = {
      str + i > int + (exp - i)
    }

    @annotation.tailrec
    def binSearch(low: Long, hi: Long): Long = {
      if (hi < low) low
      else {
        val mid = (low + hi) / 2
        //println(low, hi, mid, can(mid))
        if (can(mid)) binSearch(low, mid - 1)
        else binSearch(mid + 1, hi)
      }
    }

    val res = exp - binSearch(0, exp) + 1

    println(res)
  }
}

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

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

  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 REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    //for (_ <- 1 to nextInt()) {
    REP(nextInt()) { _ =>
      var str, int, exp = nextInt()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

object A {

  def main(args: Array[String]): Unit = {}
  val out = new java.io.PrintWriter(System.out)
  val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
  def tokenizer = new java.util.StringTokenizer(in.readLine)
  def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }

  val Array(t) = readInts(1)

  for (_ <- 1 to t) {
    val Array(str, int, exp) = readLongs(3)

    def can(i: Long) = {
      str + i > int + (exp - i)
    }

    @annotation.tailrec
    def binSearch(low: Long, hi: Long): Long = {
      if (hi < low) low
      else {
        val mid = (low + hi) / 2
        if (can(mid)) binSearch(low, mid - 1)
        else binSearch(mid + 1, hi)
      }
    }

    val res = exp - binSearch(0, exp) + 1

    out.println(res)
  }

  out.flush()
}

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

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

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream))
    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 tokenizer = new java.util.StringTokenizer(reader.readLine)
//    def readLine = reader.readLine
//    def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
//    def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }
  }

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

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    //for (_ <- 1 to nextInt()) {
    REP(nextInt()) { _ =>
      var str, int, exp = nextInt()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  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 tokenizer = new java.util.StringTokenizer(reader.readLine)
    def readLine = reader.readLine
    def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
    def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }
  }

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

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    //for (_ <- 1 to nextInt()) {
    REP(readLine.toInt) { _ =>
      var Array(str, int, exp) = readLongs(3)
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

object A {

  def main(args: Array[String]): Unit = {}
  val out = new java.io.PrintWriter(System.out)
  val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
  def tokenizer = new java.util.StringTokenizer(in.readLine)
  def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }
  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 }
  }

  val Array(t) = readInts(1)

  REP(t) { _ =>
    val Array(str, int, exp) = readLongs(3)

    def can(i: Long) = {
      str + i > int + (exp - i)
    }

    @annotation.tailrec
    def binSearch(low: Long, hi: Long): Long = {
      if (hi < low) low
      else {
        val mid = (low + hi) / 2
        if (can(mid)) binSearch(low, mid - 1)
        else binSearch(mid + 1, hi)
      }
    }

    val res = exp - binSearch(0, exp) + 1

    out.println(res)
  }

  out.flush()
}

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

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

  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 REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    for (_ <- 1 to nextInt()) {
      var str, int, exp = nextInt()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  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 REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    REP(ni()) { _ =>
      var str, int, exp = ni()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  private 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()) { _ =>
      var str, int, exp = ni()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  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 tokenizer = new java.util.StringTokenizer(reader.readLine)
//    def readLine = reader.readLine
//    def readInts(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toInt) }
//    def readLongs(n: Int) = { val tl = tokenizer; Array.fill(n)(tl.nextToken.toLong) }
  }

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

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    //for (_ <- 1 to nextInt()) {
    REP(nextInt()) { _ =>
      var str, int, exp = nextInt()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  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 REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }

}

class Main(out: java.io.PrintWriter, sc: Main.InputReader) {
  import sc._
  import Main._
  import Math.{max, min}

  def solve(): Unit = {
    REP(nextInt()) { _ =>
      var str, int, exp = nextInt()
      val s = str + int + exp
      val d = max(0 ,int - str + 1)
      str += d
      exp -= d
      val intMin = int
      val intMax = min(int + exp, s / 2 + (if (s % 2 == 0) -1 else 0))
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  private 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 str, int, exp = ni()
      val s = str + int + exp
      val intMin = int
      val intMax = s / 2 + (if (s % 2 == 0) -1 else 0)
      val ans = max(0, intMax - intMin + 1)
      out.println(ans)
    }
  }
}

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

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

  private 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 str, int, exp = ni()
      val init = str + exp
      if (init <= int) out.println(0)
      else {
        val d = init - int
        val ans = d / 2 + (if(d % 2 == 1) 1 else 0)
        out.println(ans)
      }
    }
  }
}


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

  import scala.collection.mutable
  import scala.collection.mutable.ListBuffer
  def main(args: Array[String]): Unit = {
    solve(System.in,System.out)
  }
  def solve(inputStream: InputStream, out: PrintStream): Unit = {
    val in = new InputReader(inputStream)
    val a = Array.fill(30*31)(0L)
    val s = in.next()
    def toIndx2(x: Int, y: Int): Int = x*30+y
    def toIndx(ch: Char): Int = (ch-'a'+1).toInt
    val count = Array.fill(30)(0L)
    s.zipWithIndex.foreach{ case (ch,i) =>
      val chIndex = toIndx(ch)

      (0 to 29).foreach(k => {
        a(toIndx2(k,chIndex)) += count(k)
      })

      count(chIndex) += 1

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

import collection.mutable.HashMap

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine
    val cArr = Array.ofDim[Long](26)
    val iArr = Array.ofDim[Long](s.length, 26)
    for(i <- 0 until s.length) {
      val c = s.charAt(i) - 'a'
      cArr(c) += 1
      Array.copy(cArr, 0, iArr(i), 0, cArr.size)
    }
    val pArr = Array.ofDim[Long](26, 26)
    for(i <- 1 until s.length) {
      val c = s.charAt(i) - 'a'
      for(j <- 0 until 26) {
        val cp = iArr(i - 1)(j)
        pArr(j)(c) += cp
      }
    }
    println(Math.max(pArr.map(_.max).max, cArr.max))
  }
}

import collection.mutable.HashMap

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine
    val cArr = Array.ofDim[Int](26)
    val iArr = Array.ofDim[Int](s.length, 26)
    for(i <- 0 until s.length) {
      val c = s.charAt(i) - 'a'
      cArr(c) += 1
      Array.copy(cArr, 0, iArr(i), 0, cArr.size)
    }
    val pArr = Array.ofDim[Int](26, 26)
    for(i <- 1 until s.length) {
      val c = s.charAt(i) - 'a'
      for(j <- 0 until 26) {
        val cp = iArr(i - 1)(j)
        pArr(j)(c) += cp
      }
    }
    println(Math.max(pArr.map(_.max).max, cArr.max))
  }
}

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

  import scala.collection.mutable
  import scala.collection.mutable.ListBuffer
  def main(args: Array[String]): Unit = {
    solve(System.in,System.out)
  }
  def solve(inputStream: InputStream, out: PrintStream): Unit = {
    val in = new InputReader(inputStream)
    val a = Array.fill(27*27+27)(0)
    val s = in.next()
    def toIndx2(x: Int, y: Int): Int = x*27+y
    def toIndx(ch: Char): Int = (ch-'a').toInt
    val count = Array.fill(27)(0)
    s.zipWithIndex.foreach{ case (ch,i) =>
      val chIndex = toIndx(ch)

      (0 to 26).foreach(k => {
        a(toIndx2(k,chIndex)) += count(k)
      })

      count(chIndex) += 1

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


object Solution extends App {
  val in = io.Source.stdin.getLines()
  val Array(n, x0) = in.next().split(' ').map(_.toInt)
  val answer = Array.ofDim[Int](1002)

  in.take(n).foreach { line =>
    val Array(a, b) = line.split(' ').map(_.toInt).sorted
    answer(a) += 1
    answer(b + 1) -= 1
  }

  val (a, _) = answer.indices.foldLeft(-1, 0) {
    case ((distance, sumSoFar), i) =>
      val nSum = sumSoFar + answer(i)
      if (nSum == n && (distance == -1 || Math.abs(x0 - i) < distance))
        (Math.abs(x0 - i), nSum)
      else
        (distance, nSum)
  }

  println(a)
}

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

object B {

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

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

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

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

  def comp(x: (Int, Int), y: (Int, Int)): Boolean = {
    if (x._1 != y._1) x._1 < y._1 else x._2 < y._2
  }

  def solve = {
    val n = nextInt
    val x0 = nextInt
    val ranges = new Array[(Int, Int)](n)
    for (i <- 0 until n) {
      val a = nextInt
      val b = nextInt
      ranges(i) = (Math.min(a, b), Math.max(a, b))
    }
    ranges.sortWith(comp)
    var start = 0
    var finish = Int.MaxValue
    for (i <- 0 until n) {
      start = Math.max(start, ranges(i)._1)
      finish = Math.min(finish, ranges(i)._2)
    }
    if (start > finish) {
      out.println(-1)
    } else {
      var ans = Int.MaxValue
      for (i <- start to finish) {
        if (Math.abs(x0 - i) < ans) {
          ans = Math.abs(x0 - i)
        }
      }
      out.println(ans)
    }
  }

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


import scala.io.StdIn

/**
  * Created by hsleep on 2016. 1. 7..
  */
object C {
  def main(args: Array[String]): Unit = {
    val k = StdIn.readInt()
    makeOutput(k).foreach(println)
  }

  def makeOutput(k: Int): Seq[String] = {
    k match {
      case 0 => Seq("+")
      case _ =>
        val input = makeOutput(k - 1)
        input.flatMap { s =>
          Seq(s + s, s + makeOpposite(s))
        }
    }
  }

  def makeOpposite(s: String): String = {
    s.map {
      case '+' => '*'
      case '*' => '+'
    }
  }
}

import scala.io.StdIn

/**
  * Created by hsleep on 2016. 1. 7..
  */
object CSolution extends App {
  val k = StdIn.readInt()

  def makeOpposite(s: String): String = {
    s.map {
      case '+' => '*'
      case '*' => '+'
    }
  }

  def makeOutput(k: Int): Seq[String] = {
    k match {
      case 0 => Seq("+")
      case _ =>
        val input = makeOutput(k - 1)
        input.flatMap { s =>
          Seq(s + s, s + makeOpposite(s))
        }
    }
  }

  makeOutput(k).foreach(println)
}


import java.util.Scanner

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

object Btask extends App {

  var line = new Scanner(StdIn.readLine())
  val n = line.nextInt()
  var matrix = ArrayBuffer[String]()
  for (i <- 0 until n) {
    line = new Scanner(StdIn.readLine())
    var matrixString = line.next()
    matrix.append(matrixString)
  }
  for (i <- 0 until n) {
    val evenChars = matrix(i).chars.filter(_ % 2 == 0).sorted().toArray
    val oddChars = matrix(i).chars.filter(_ % 2 == 1).sorted().toArray
    if (evenChars.isEmpty) {
      println(oddChars.map(_.toChar).mkString)
    } else {
      if (oddChars.isEmpty) {
        println(evenChars.map(_.toChar).mkString)
      } else {
        if (Math.abs(evenChars(evenChars.size - 1) - oddChars(0)) != 1) {
          println(evenChars.map(_.toChar).mkString + oddChars.map(_.toChar).mkString)
        } else {
          if (Math.abs(oddChars(oddChars.size - 1) - evenChars(0)) != 1) {
            println(oddChars.map(_.toChar).mkString + evenChars.map(_.toChar).mkString)
          } else {
            println("No answer")
          }
        }
      }
    }
  }
}

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 S = ns()
      val C = Array.ofDim[Int](26)
      REP(S.length) { i =>
        C(S(i) - 'a') += 1
      }
      val even, odd = ArrayBuffer[Int]()
      REP(26) { i =>
        if (C(i) > 0) {
          (if (i % 2 == 0) even else odd) += i
        }
      }

      def sort(): Boolean = {
        REP(even.length) { i =>
          REP(odd.length) { j =>
            if (abs(even(i) - odd(j)) > 1) {
              even += even.remove(i)
              odd.insert(0, odd.remove(j))
              return true
            }
          }
        }
        false
      }

      def printAns(): Unit = {
        (even ++ odd).foreach { i =>
          REP(C(i)) { _ =>
            out.print(('a' + i).toChar)
          }
        }
        out.println()
      }

      if (even.isEmpty || odd.isEmpty) {
        printAns()
      } else {
        if (!sort()) {
          out.println("No answer")
        } else {
          printAns()
        }
      }

    }
  }
}


import scala.collection.mutable

// https://codeforces.com/contest/914/problem/F
object F extends App {

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

  val s = readLine.toCharArray.map(_ - 'a')
  val n = s.length
  val Array(q) = readInts(1)

  val masks = Array.fill('z' - 'a' + 1) { new mutable.BitSet(n) with BitShifts }
  for (i <- 0 until n) masks(s(i)) += i

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  val ones = new mutable.BitSet(n)
  for (i <- 0 until n) ones += i
  val onesBits = ones.toBitMask

  for (_ <- 1 to q) {
    val cmd = readLine
    if (cmd.head == '1') {
      val Array(_, posS, cs) = cmd.split(" ")
      val pos = posS.toInt - 1
      val c = cs.head - 'a'
      masks(s(pos)) -= pos
      masks(c) += pos
      s(pos) = c
    } else {
      val Array(_, lS, rS, y) = cmd.split(" ")
      val l = lS.toInt - 1
      val r = rS.toInt - 1
      val cnt = if (r - l + 1 < y.length) 0
      else {
        val bits = new mutable.BitSet(onesBits.clone) with BitShifts
        for (i <- 0 until y.length) bits &= masks(y(i) - 'a') >> i
        (bits >> l).size - (bits >> (r - y.length + 2)).size
      }
      println(cnt)
    }
  }

  Console.flush

  trait BitShifts {
    this: mutable.BitSet =>

    private def <<(shiftBy: Int): mutable.BitSet = {

      val bitOffset = shiftBy & 63
      val wordOffset = shiftBy >>> 6

      var significantWordCount = this.nwords
      while (significantWordCount > 0 && this.word(significantWordCount - 1) == 0) {
        significantWordCount -= 1
      }

      val bits = if (bitOffset == 0) {
        val newSize = significantWordCount + wordOffset
        val newBits = Array.ofDim[Long](newSize)
        var i = wordOffset
        while (i < newSize) {
          newBits(i) = this.word(i - wordOffset)
          i += 1
        }
        newBits
      } else {
        val revBitOffset = 64 - bitOffset
        val extraBits = this.word(significantWordCount - 1) >>> revBitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = significantWordCount + wordOffset + extraWordCount
        val newBits = Array.ofDim[Long](newSize)
        var previous = 0L
        var i = 0
        while (i < significantWordCount) {
          val current = this.word(i)
          newBits(i + wordOffset) = (previous >>> revBitOffset) | (current << bitOffset)
          previous = current
          i += 1
        }
        if (extraWordCount != 0) newBits(newSize - 1) = extraBits
        newBits
      }

      this.fromBitMaskNoCopy(bits)
    }

    def >>(shiftBy: Int): mutable.BitSet = {

      val bitOffset = shiftBy & 63

      val bits = if (bitOffset == 0) {
        val wordOffset = shiftBy >>> 6
        val newSize = this.nwords - wordOffset
        if (newSize > 0) {
          val newBits = Array.ofDim[Long](newSize)
          var i = 0
          while (i < newSize) {
            newBits(i) = this.word(i + wordOffset)
            i += 1
          }
          newBits
        } else Array.emptyLongArray
      } else {
        val wordOffset = (shiftBy >>> 6) + 1
        val extraBits = this.word(this.nwords - 1) >>> bitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = this.nwords - wordOffset + extraWordCount
        if (newSize > 0) {
          val revBitOffset = 64 - bitOffset
          val newBits = Array.ofDim[Long](newSize)
          var previous = this.word(wordOffset - 1)
          var i = wordOffset
          while (i < this.nwords) {
            val current = this.word(i)
            newBits(i - wordOffset) = (previous >>> bitOffset) | (current << revBitOffset)
            previous = current
            i += 1
          }
          if (extraWordCount != 0) newBits(newSize - 1) = extraBits
          newBits
        } else Array.emptyLongArray
      }

      this.fromBitMaskNoCopy(bits)
    }
  }

}

import scala.collection.mutable

// https://codeforces.com/contest/914/problem/F
object F extends App {

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

  val s = readLine.toCharArray.map(_ - 'a')
  val n = s.length
  val Array(q) = readInts(1)

  val masks = Array.fill('z' - 'a' + 1) { new mutable.BitSet(n) with BitShifts }
  for (i <- 0 until n) masks(s(i)) += i

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  val ones = new mutable.BitSet(n)
  for (i <- 0 until n) ones += i
  val onesBits = ones.toBitMask

  for (_ <- 1 to q) {
    val cmd = readLine
    if (cmd.head == '1') {
      val Array(_, posS, cs) = cmd.split(" ")
      val pos = posS.toInt - 1
      val c = cs.head - 'a'
      masks(s(pos)) -= pos
      masks(c) += pos
      s(pos) = c
    } else {
      val Array(_, lS, rS, y) = cmd.split(" ")
      val l = lS.toInt - 1
      val r = rS.toInt - 1
      val cnt = if (r - l + 1 < y.length) 0
      else {
        val bits = new mutable.BitSet(onesBits.clone) with BitShifts
        for (i <- 0 until y.length) bits &= masks(y(i) - 'a') >> i
        (bits >> l).size - (bits >> (r - y.length + 2)).size
      }
      println(cnt)
    }
  }

  Console.flush

  trait BitShifts {
    this: mutable.BitSet =>

    val LogWL = 6
    val WordLength = 1 << LogWL
    val WordMask = WordLength - 1
    val MaxSize = (Int.MaxValue >> LogWL) + 1

    def <<(shiftBy: Int): mutable.BitSet = {

      val shiftedBits = if (this.nwords == 0 || this.nwords == 1 && this.word(0) == 0) Array.emptyLongArray
      else if (shiftBy > 0) shiftLeft(shiftBy)
      else if (shiftBy == 0) this.elems.clone()
      else shiftRight(-shiftBy)

      new mutable.BitSet(shiftedBits) with BitShifts
    }

    def >>(shiftBy: Int): mutable.BitSet = {

      val shiftedBits = if (this.nwords == 0 || this.nwords == 1 && this.word(0) == 0) Array.emptyLongArray
      else if (shiftBy > 0) shiftRight(shiftBy)
      else if (shiftBy == 0) this.elems.clone()
      else shiftLeft(-shiftBy)

      new mutable.BitSet(shiftedBits) with BitShifts
    }

    def <<=(shiftBy: Int): mutable.BitSet = {

      if (this.nwords == 0 || this.nwords == 1 && this.word(0) == 0) ()
      else if (shiftBy > 0) shiftLeftInPlace(shiftBy)
      else if (shiftBy < 0) shiftRightInPlace(-shiftBy)

      this
    }

    def >>=(shiftBy: Int): mutable.BitSet = {

      if (this.nwords == 0 || this.nwords == 1 && this.word(0) == 0) ()
      else if (shiftBy > 0) shiftRightInPlace(shiftBy)
      else if (shiftBy < 0) shiftLeftInPlace(-shiftBy)

      this
    }

    private def shiftLeft(shiftBy: Int): Array[Long] = {

      val bitOffset = shiftBy & WordMask
      val wordOffset = shiftBy >>> LogWL

      var significantWordCount = this.nwords
      while (significantWordCount > 0 && this.word(significantWordCount - 1) == 0) {
        significantWordCount -= 1
      }

      if (bitOffset == 0) {
        val newSize = significantWordCount + wordOffset
        require(newSize <= MaxSize)
        val newBits = Array.ofDim[Long](newSize)
        var i = wordOffset
        while (i < newSize) {
          newBits(i) = this.word(i - wordOffset)
          i += 1
        }
        newBits
      } else {
        val revBitOffset = WordLength - bitOffset
        val extraBits = this.word(significantWordCount - 1) >>> revBitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = significantWordCount + wordOffset + extraWordCount
        require(newSize <= MaxSize)
        val newBits = Array.ofDim[Long](newSize)
        var previous = 0L
        var i = 0
        while (i < significantWordCount) {
          val current = this.word(i)
          newBits(i + wordOffset) = (previous >>> revBitOffset) | (current << bitOffset)
          previous = current
          i += 1
        }
        if (extraWordCount != 0) newBits(newSize - 1) = extraBits
        newBits
      }
    }

    private def shiftRight(shiftBy: Int): Array[Long] = {

      val bitOffset = shiftBy & WordMask

      if (bitOffset == 0) {
        val wordOffset = shiftBy >>> LogWL
        val newSize = this.nwords - wordOffset
        if (newSize > 0) {
          val newBits = Array.ofDim[Long](newSize)
          var i = 0
          while (i < newSize) {
            newBits(i) = this.word(i + wordOffset)
            i += 1
          }
          newBits
        } else Array.emptyLongArray
      } else {
        val wordOffset = (shiftBy >>> LogWL) + 1
        val extraBits = this.word(this.nwords - 1) >>> bitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = this.nwords - wordOffset + extraWordCount
        if (newSize > 0) {
          val revBitOffset = WordLength - bitOffset
          val newBits = Array.ofDim[Long](newSize)
          var previous = this.word(wordOffset - 1)
          var i = wordOffset
          while (i < this.nwords) {
            val current = this.word(i)
            newBits(i - wordOffset) = (previous >>> bitOffset) | (current << revBitOffset)
            previous = current
            i += 1
          }
          if (extraWordCount != 0) newBits(newSize - 1) = extraBits
          newBits
        } else Array.emptyLongArray
      }
    }

    private def shiftLeftInPlace(shiftBy: Int): Unit = {

      val bitOffset = shiftBy & WordMask
      val wordOffset = shiftBy >>> LogWL

      var significantWordCount = this.nwords
      while (significantWordCount > 0 && this.word(significantWordCount - 1) == 0) {
        significantWordCount -= 1
      }

      if (bitOffset == 0) {
        val newSize = significantWordCount + wordOffset
        require(newSize <= MaxSize)
        ensureCap(newSize)
        System.arraycopy(this.elems, 0, this.elems, wordOffset, significantWordCount)
      } else {
        val revBitOffset = WordLength - bitOffset
        val extraBits = this.elems(significantWordCount - 1) >>> revBitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = significantWordCount + wordOffset + extraWordCount
        require(newSize <= MaxSize)
        ensureCap(newSize)
        var i = significantWordCount - 1
        var previous = this.elems(i)
        while (i > 0) {
          val current = this.elems(i - 1)
          this.elems(i + wordOffset) = (current >>> revBitOffset) | (previous << bitOffset)
          previous = current
          i -= 1
        }
        this.elems(wordOffset) = previous << bitOffset
        if (extraWordCount != 0) this.elems(newSize - 1) = extraBits
      }
      java.util.Arrays.fill(this.elems, 0, wordOffset, 0)
    }

    private def shiftRightInPlace(shiftBy: Int): Unit = {

      val bitOffset = shiftBy & WordMask

      if (bitOffset == 0) {
        val wordOffset = shiftBy >>> LogWL
        val newSize = this.nwords - wordOffset
        if (newSize > 0) {
          System.arraycopy(this.elems, wordOffset, this.elems, 0, newSize)
          java.util.Arrays.fill(this.elems, newSize, this.nwords, 0)
        } else this.clear()
      } else {
        val wordOffset = (shiftBy >>> LogWL) + 1
        val extraBits = this.elems(this.nwords - 1) >>> bitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = this.nwords - wordOffset + extraWordCount
        if (newSize > 0) {
          val revBitOffset = WordLength - bitOffset
          var previous = this.elems(wordOffset - 1)
          var i = wordOffset
          while (i < this.nwords) {
            val current = this.elems(i)
            this.elems(i - wordOffset) = (previous >>> bitOffset) | (current << revBitOffset)
            previous = current
            i += 1
          }
          if (extraWordCount != 0) this.elems(newSize - 1) = extraBits
          java.util.Arrays.fill(this.elems, newSize, this.nwords, 0)
        } else this.clear()
      }
    }

    protected final def ensureCap(idx: Int): Unit = {
      // Copied from mutable.BitSet.ensureCapacity (which is inaccessible from here).
      require(idx < MaxSize)
      if (idx >= this.nwords) {
        var newlen = this.nwords
        while (idx >= newlen) newlen = math.min(newlen * 2, MaxSize)
        val elems1 = new Array[Long](newlen)
        Array.copy(this.elems, 0, elems1, 0, this.nwords)
        this.elems = elems1
      }
    }

  }

}

import scala.collection.mutable

// https://codeforces.com/contest/914/problem/F
object F extends App {

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

  val s = readLine.toCharArray.map(_ - 'a')
  val n = s.length
  val Array(q) = readInts(1)

  val masks = Array.fill('z' - 'a' + 1) { new BitSetWithShift(n) }
  for (i <- 0 until n) masks(s(i)) += i

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  val ones = new mutable.BitSet(n)
  for (i <- 0 until n) ones += i
  val onesBits = ones.toBitMask

  for (_ <- 1 to q) {
    val cmd = readLine
    if (cmd.head == '1') {
      val Array(_, posS, cs) = cmd.split(" ")
      val pos = posS.toInt - 1
      val c = cs.head - 'a'
      masks(s(pos)) -= pos
      masks(c) += pos
      s(pos) = c
    } else {
      val Array(_, lS, rS, y) = cmd.split(" ")
      val l = lS.toInt - 1
      val r = rS.toInt - 1
      val cnt = if (r - l + 1 < y.length) 0
      else {
        val bits = new BitSetWithShift(onesBits)
        for (i <- 0 until y.length) bits &= masks(y(i) - 'a') >> i
        (bits >> l).size - (bits >> (r - y.length + 2)).size
      }
      println(cnt)
    }
  }

  Console.flush

  class BitSetWithShift(elems: Array[Long]) extends mutable.BitSet(elems.clone) {

    def this(initSize: Int) = this(new Array[Long]((initSize + 63) >> 6 max 1))

    def >>(shiftBy: Int): mutable.BitSet = {

      val bitOffset = shiftBy & 63

      val bits = if (bitOffset == 0) {
        val wordOffset = shiftBy >>> 6
        val newSize = this.nwords - wordOffset
        if (newSize > 0) {
          val newBits = Array.ofDim[Long](newSize)
          var i = 0
          while (i < newSize) {
            newBits(i) = this.word(i + wordOffset)
            i += 1
          }
          newBits
        } else Array.emptyLongArray
      } else {
        val wordOffset = (shiftBy >>> 6) + 1
        val extraBits = this.word(this.nwords - 1) >>> bitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = this.nwords - wordOffset + extraWordCount
        if (newSize > 0) {
          val revBitOffset = 64 - bitOffset
          val newBits = Array.ofDim[Long](newSize)
          var previous = this.word(wordOffset - 1)
          var i = wordOffset
          while (i < this.nwords) {
            val current = this.word(i)
            newBits(i - wordOffset) = (previous >>> bitOffset) | (current << revBitOffset)
            previous = current
            i += 1
          }
          if (extraWordCount != 0) newBits(newSize - 1) = extraBits
          newBits
        } else Array.emptyLongArray
      }

      mutable.BitSet.fromBitMaskNoCopy(bits)
    }
  }

}

import scala.collection.mutable

// https://codeforces.com/contest/914/problem/F
object F extends App {

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

  val s = readLine.toCharArray.map(_ - 'a')
  val n = s.length
  val Array(q) = readInts(1)

  val masks = Array.fill('z' - 'a' + 1) { new BitSetWithShift(n) }
  for (i <- 0 until n) masks(s(i)) += i

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  val ones = new mutable.BitSet(n)
  for (i <- 0 until n) ones += i
  val onesBits = ones.toBitMask

  for (_ <- 1 to q) {
    val cmd = readLine
    if (cmd.head == '1') {
      val Array(_, posS, cs) = cmd.split(" ")
      val pos = posS.toInt - 1
      val c = cs.head - 'a'
      masks(s(pos)) -= pos
      masks(c) += pos
      s(pos) = c
    } else {
      val Array(_, lS, rS, y) = cmd.split(" ")
      val l = lS.toInt - 1
      val r = rS.toInt - 1
      val ans = new BitSetWithShift(onesBits)
      for (i <- 0 until y.length) ans &= masks(y(i) - 'a') >> i
      val cnt = (ans >> (l)).size - (ans >> (r - y.length + 2)).size
      println(cnt)
    }
  }

  Console.flush

  class BitSetWithShift(elems: Array[Long]) extends mutable.BitSet(elems.clone) {

    def this(initSize: Int) = this(new Array[Long]((initSize + 63) >> 6 max 1))

    def >>(shiftBy: Int): mutable.BitSet = {

      val bitOffset = shiftBy & 63

      val bits = if (bitOffset == 0) {
        val wordOffset = shiftBy >>> 6
        val newSize = this.nwords - wordOffset
        if (newSize > 0) {
          val newBits = Array.ofDim[Long](newSize)
          var i = 0
          while (i < newSize) {
            newBits(i) = this.word(i + wordOffset)
            i += 1
          }
          newBits
        } else Array.emptyLongArray
      } else {
        val wordOffset = (shiftBy >>> 6) + 1
        val extraBits = this.word(this.nwords - 1) >>> bitOffset
        val extraWordCount = if (extraBits == 0) 0 else 1
        val newSize = this.nwords - wordOffset + extraWordCount
        if (newSize > 0) {
          val revBitOffset = 64 - bitOffset
          val newBits = Array.ofDim[Long](newSize)
          var previous = this.word(wordOffset - 1)
          var i = wordOffset
          while (i < this.nwords) {
            val current = this.word(i)
            newBits(i - wordOffset) = (previous >>> bitOffset) | (current << revBitOffset)
            previous = current
            i += 1
          }
          if (extraWordCount != 0) newBits(newSize - 1) = extraBits
          newBits
        } else Array.emptyLongArray
      }

      mutable.BitSet.fromBitMaskNoCopy(bits)
    }
  }

}


//scala ACM模式读入读出
import scala.io.StdIn
import scala.math._

object Problem_1716A {
  def main(args: Array[String]): Unit = {
	var t=StdIn.readInt;
	while(t>0){
		t=t-1;
		var n=StdIn.readInt;
		if(n%3==0) println(n/3);
	    if(n%3==1) println(n/3+2- {if(n!=1) 1; else 0;});
	    if(n%3==2) println(n/3+1);

	}
  }
}

import scala.io.StdIn._

object Solution {
  def main(args: Array[String]): Unit = {
    for (t <- 1 to readInt()) {
      val n = readInt()
      val ans = if (n == 1) {
        2
      } else if (n == 2) {
        1
      } else {
        (n + 2) / 3
      }
      println(ans)
    }
  }
}

object A extends App {
  import java.io.{BufferedReader, InputStreamReader, StreamTokenizer}

  solve()

  @inline def operations(n: Int): Int = {
    if (n == 1){
      2
    } else
    if (n == 2) {
      1
    } else {
      val s = n / 3
      n % 3 match {
        case 0 => s
        case _ => s + 1
      }
    }
  }

  def solve(): Unit = {
    val in = new StreamTokenizer(new BufferedReader(new InputStreamReader((System.in))))

    @inline def nextInt = {
      in.nextToken()
      in.nval.asInstanceOf[Int]
    }

    val t = nextInt
    for (_ <- 1 to t) {
      val n = nextInt
      println(operations(n))
    }
  }

}

//scala ACM模式读入读出
import scala.io.StdIn
import scala.math._

object Problem_1716A {
  def main(args: Array[String]): Unit = {
	var t=StdIn.readInt;
	while(t>0){
		t=t-1;
		var n=StdIn.readInt;
		if(n%3==0) println(n/3);
	    if(n%3==1) println(n/3-2- {if(n!=1) 1; else 0;});
	    if(n%3==2) println(n/3+1);

	}
  }
}

//scala ACM模式读入读出
import scala.io.StdIn
import scala.math._

object Problem_1716A {
  def main(args: Array[String]): Unit = {
	var t=StdIn.readInt;
	while(t>0){
		t=t-1;
		var n=StdIn.readInt;
		if(n%3==0) println(n/3);
	    if(n%3==1) println(n/3-n- {if(n!=1) 1; else 0;});
	    if(n%3==2) println(n/3+1);

	}
  }
}


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

  val t = readInt()

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

    val (l, r) = (an zip an.tail).maxBy { case (l, r) => l * r }

    val ans = l * r

    println(ans)
  }
}

import scala.io.StdIn._;

object Main extends App {

  def a(ignored: Int, z: Array[Long]): Long = z.zip(z.slice(1, z.length)).map(l => l._1 * l._2).max

  for (_ <- 0 until readInt()) println(a(readInt(), readLine().split(" ").map(_.toLong)))
}

import java.io.PrintWriter

import scala.collection.immutable.TreeSet
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import util.control.Breaks._

object Solution {
    val reader = scala.io.StdIn
    def readInt(): Int = reader.readLine().toInt
    def readArrayInt(): Array[Int] = reader.readLine().split(" ").map(_.toInt)
    def readArrayLong(): Array[Long] = reader.readLine().split(" ").map(_.toLong)
    def readString(): String = reader.readLine()

    def multiTest(f: Int => Unit): Unit = {
        val t = readInt()
        for (i <- 1 to t) f(i)
    }

    def GCD(a: Int, b: Int): Int = {
        if (a == 0) return b
        GCD(b % a, a)
    }

    def solve(t: Int = 0): Unit = {
        var t = readInt()
        while (t > 0) {
            val n =readInt()
            val a = readArrayInt()
            var max = 0L
            for (i <- 0 until n - 1) {
                if (a(i).toLong * a(i+1) > max) {
                    max = a(i).toLong * a(i+1)
                }
            }
            println(max)
            t -= 1
        }

    }

    def main(args: Array[String]) {
        //multiTest(solve)
        solve()
    }
}

import scala.io.StdIn._;

object Main extends App {

  def a(ignored: Int, z: Array[Int]): Int = z.zip(z.slice(1, z.length)).map(l => l._1 * l._2).max

  for (_ <- 0 until readInt()) print(a(readInt(), readLine().split(" ").map(_.toInt)))
}


import scala.collection.mutable.ArrayBuffer

object Flask {
  class Result(var games:Int, var time:Int) {
    override def toString = games + ": " + time
  }

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

    var data:ArrayBuffer[Result] = new ArrayBuffer()
    (1 to n).foreach(i => {
      input = readLine.split(" ").map(_.toInt)
      data += new Result(input(0), input(1))
    })

    data = data.sortWith((x, y) => x.games > y.games || (x.games == y.games && x.time < y.time))
    var item = data(k - 1)
    println(data.count(x => x.games == item.games && x.time == item.time))
  }
}

object A166 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val arr = Array.fill(n)(readInts(2)).map(x => (x(0), x(1))).sortWith{ case ((a1, b1), (a2, b2)) =>
        if(a1 > a2) {
          true
        } else if (a1 == a2) {
          if (b1 < b2) true
          else false
        } else {
          false
        }
    }

//    for((x,y) <- arr) println(s"$x $y")

    val target = arr(k-1)

    // firstGreaterOrEqualBinarySearch
    var first = -1

    {
      var low = 0
      var high = n - 1

      while(low < high) {
        val mid = low + (high - low)/2
        if((arr(mid)._1 > target._1) || (arr(mid)._1 == target._1 && arr(mid)._2 < target._2))
          low = mid + 1
        else
          high = mid

//        println(s"$low, $high, $mid")
      }

      first = low
    }

    //lastSame
    val last = arr.lastIndexOf(target)

    out.println(last-first+1)

    out.close()
  }

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

}

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

object P166A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)
  val N, K = sc.nextInt
  val PT = List.fill(N, 2)(sc.nextLong)

  def solve(): Int = {

    val groups = PT.groupBy[Long] {
        case List(p, t) => p * Int.MaxValue - t
      }.toSeq.sortWith(_._1 > _._1).map(_._2.size) toList

    @tailrec
    def loop(acc: Int, gs: List[Int]): Int = gs match {
        case x :: Nil => x
        case x :: xs => if (acc + x > K) x
                        else loop(acc + x, xs)
      }

    loop(1, groups)
  }

  out.println(solve)
  out.close
}

object CF166A {

  def main(args: Array[String]): Unit = {
    var Array(n, k) = Console.readLine.split(' ').map(_.toInt)
    var teams: List[(Int, Int)] = List()
    for (i <- 0.until(n)) {
      val Array(p, t) = Console.readLine.split(' ').map(_.toInt)
      teams ++= List((p, t))
    }
    teams = teams.sort((a1, a2) => (a1._1 > a2._1 || a1._1 == a2._1 && a1._2 < a2._2))
    var cnt = 1
    var at = 1
    while (at < k) {
      if (teams(at) == teams(at - 1)) {
        cnt += 1
      } else {
        cnt = 1
      }
      at += 1
    }
    while (at < n && teams(at) == teams(at - 1)) {
      cnt += 1
      at += 1
    }
    println(cnt)
  }
}

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

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

  val Array(n, k) = readInts
  val results = (for(_ <- 1 to n) yield readInts).map(x => (50 - x(0)) * 100 + x(1)).sorted
  def ans = results.count(_.equals(results(k - 1)))

  def main(a: Array[String]) {
    println(ans)
  }
}

object Main {
  def main(args: Array[String]) = {
    val nk = readLine().split(" ").map(_.toInt)
    val n = nk(0)
    val k = nk(1)

    val a = (1 to n).map(_ => readLine().split(" ").map(_.toInt))
    val sorted = a.sortWith((a1, a2) => a1(0) > a2(0) || (a1(0) == a2(0) && a1(1) < a2(1)))
    val e = sorted(k - 1)
    val count = sorted.count(a0 => a0(0) == e(0) && a0(1) == e(1))
    println(count)
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 < y._2
      else false
    }

    A = A.sortWith(compare)

    println(A.count(_ == A(k - 1)))
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = (1 to n).map { _ =>
    val d = in.next().split(" ").map(_.toInt)
    (-d.head, d.last)
  }.sorted
  val kth = data(k - 1)
  println(data.count(_ == kth))
}

object A166 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val arr = Array.fill(n)(readInts(2)).map(x => (x(0), x(1))).sortWith{ case ((a1, b1), (a2, b2)) =>
        if(a1 > a2) {
          true
        } else if (a1 == a2) {
          if (b1 < b2) true
          else false
        } else {
          false
        }
    }

//    for((x,y) <- arr) println(s"$x $y")

    val target = arr(k-1)

    // firstGreaterOrEqualBinarySearch
    var first = -1

    {
      var low = 0
      var high = n - 1

      while(low < high) {
        val mid = low + (high - low)/2
        if((arr(mid)._1 > target._1) || (arr(mid)._1 == target._1 && arr(mid)._2 < target._2))
          low = mid + 1
        else
          high = mid

//        println(s"$low, $high, $mid")
      }

      first = low
    }

    //lastSame
    var last = -1

    {
      var low = 0
      var high = n - 1

      while(low < high) {
        val mid = low + (high - low + 1)/2
//        println(s"$low, $high, $mid")
//        println(arr(low), arr(mid), arr(high), target)
        if((arr(mid)._1 > target._1) || (arr(mid)._1 == target._1 && arr(mid)._2 <= target._2))
          low = mid
        else
          high = mid - 1

//        println(s"\n\n\n$low, $high, $mid\n\n\n")
      }

      last = low
    }

    out.println(last-first+1)

    out.close()
  }

  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")))
    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 P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    val T = (A.sortWith(compare)).distinct

    val size = T.size
    var cnt = A.count(_ == T(0)) //I = numarul de locuri pe care le impart cei de pe pozitia total + 1
    var total = 0 // I = numarul de locuri deja ocupate
    var index = 1
    var oldcnt = 0
    while(total < k && index < size) {
      total += cnt
      oldcnt = cnt
      cnt = A.count(_ == T(index))
      index += 1
    }
    // total >= k
    if(index == size) println(cnt)
    else println(oldcnt)
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    val T = (A.sortWith(compare)).distinct

    val size = T.size
    var cnt = A.count(_ == T(0))
    var total = cnt
    var index = 1
    while(total <= k && index < size) {
      cnt = A.count(_ == T(index))
      total += 1
      index += 1
    }

    println(cnt)
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    A = A.sortWith(compare)

    println(A.count(_ == A(k - 1)))
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    val T = (A.sortWith(compare)).distinct

    val size = T.size
    var end = A.count(_ == T(0))
    var start = 0
    // de la (start, start + end])
    var index = 1
    while(start + end < k && index < size) {
      start += end
      end = A.count(_ == T(index))
      index += 1
    }
    println(end)
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    A = A.sortWith(compare)

    println(A.count(_ == A(k)))
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    val T = (A.sortWith(compare)).distinct

    val size = T.size
    var cnt = A.count(_ == T(0))
    var total = cnt
    var index = 1
    while(total < k && index < size) {
      cnt = A.count(_ == T(index))
      total += 1
      index += 1
    }

    println(cnt)
  }
}

import scala.collection.mutable.ArrayBuffer

object Flask {
  class Result(var games:Int, var time:Int) {
    override def toString = games + ": " + time
  }

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

    var data:ArrayBuffer[Result] = new ArrayBuffer()
    (1 to n).foreach(i => {
      input = readLine.split(" ").map(_.toInt)
      data += new Result(input(0), input(1))
    })

    data = data.sortWith((x, y) => x.games > y.games || (x.games == y.games && x.time < y.time))
    var item = data(k)
    println(data.count(x => x.games == item.games && x.time == item.time))
  }
}

import scala.collection.mutable.ArrayBuffer

object Flask {
  class Result(var games:Int, var time:Int) { }

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

    var data:ArrayBuffer[Result] = new ArrayBuffer()
    (1 to n).foreach(i => {
      input = readLine.split(" ").map(_.toInt)
      data += new Result(input(0), input(1))
    })

    data.sortWith((x, y) => x.games > y.games || (x.games == y.games && x.time < y.time))
    var item = data(k)
    println(data.count(x => x.games == item.games && x.time == item.time))
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = (1 to n).map { _ =>
    val d = in.next().split(" ").map(_.toInt)
    (-d.head, d.last)
  }.sorted
  println(data)
  val kth = data(k - 1)
  println(data.count(_ == kth))
}

object A166 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val arr = Array.fill(n)(readInts(2)).map(x => (x(0), x(1))).sortWith{ case ((a1, b1), (a2, b2)) =>
        if(a1 > a2) {
          true
        } else if (a1 == a2) {
          if (b1 < b2) true
          else false
        } else {
          false
        }
    }

    val target = arr(k-1)

    // firstGreaterOrEqualBinarySearch
    var first = -1

    {
      var low = 0
      var high = n - 1

      while(low < high) {
        val mid = low + (high - low)/2
        if((arr(mid)._1 > target._1) || (arr(mid)._1 == target._1 && arr(mid)._2 > target._2))
          low = mid + 1
        else
          high = mid
      }

      first = low
    }

    //lastSame
    val last = arr.lastIndexOf(target)

    out.println(last-first+1)

    out.close()
  }

  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")))
    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 A166 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val arr = Array.fill(n)(readInts(2)).map(x => (x(0), x(1))).sorted.reverse
    val target = arr(k-1)

    // firstGreaterOrEqualBinarySearch
    var first = -1

    {
      var low = 0
      var high = n - 1

      while(low < high) {
        val mid = low + (high - low)/2
        if((arr(mid)._1 > target._1) || (arr(mid)._1 == target._1 && arr(mid)._2 > target._2))
          low = mid + 1
        else
          high = mid
      }

      first = low
    }

    //lastSame
    val last = arr.lastIndexOf(target)

    out.println(last-first+1)

    out.close()
  }

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

}

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

object P166A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)
  val N, K = sc.nextInt
  val PT = List.fill(N, 2)(sc.nextLong)

  def solve(): Int = {

    val groups = PT.groupBy[Long] {
        case List(p, t) => p * Int.MaxValue - t
      }.toSeq.sortWith(_._1 > _._1).map(_._2.size) toList

    @tailrec
    def loop(acc: Int, gs: List[Int]): Int = gs match {
        case x :: Nil => x
        case x :: xs => if (acc + x >= K) x
                        else loop(acc + x, xs)
      }

    loop(1, groups)
  }

  out.println(solve)
  out.close
}

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

    val a = (1 to n).map(_ => readLine().split(" ").map(_.toInt))
    val sorted = a.sortWith((a1, a2) => a1(0) < a2(0) || a1(1) > a2(1))
    val e = sorted(k - 1)
    val count = sorted.count(a0 => a0(0) == e(0) && a0(1) == e(1))
    println(count)
  }
}

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

    val a = (1 to n).map(_ => readLine().split(" ").map(_.toInt))
    val sorted = a.sortWith((a1, a2) => a1(0) > a2(0) || (a1(0) == a2(0) && a1(1) < a2(1)))
    val e = sorted(k - 1)
    val count = sorted.count(a0 => a0(0) == e(0) && a0(1) == e(1))
    println(count)
  }
}

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

    val a = (1 to n).map(_ => readLine().split(" ").map(_.toInt))
    val sorted = a.sortWith((a1, a2) => a1(0) < a2(0) || (a1(0) == a2(0) && a1(1) > a2(1)))
    val e = sorted(k - 1)
    val count = sorted.count(a0 => a0(0) == e(0) && a0(1) == e(1))
    println(count)
  }
}

object P166A {
  def readPair : (Int, Int) = {
    val x = readLine().split(" ").map(_.toInt)
    (x(0), x(1))
  }

  def main ( args : Array[String] ) {
    val x = readPair
    val n = x._1
    val k = x._2

    var A = new Array(n) : Array[(Int,Int)]

    for(i <- 0 until n) A(i) = readPair

    def compare(x : (Int, Int), y : (Int, Int)) = {
      if(x._1 > y._1) true
      else if(x._1 == y._1) x._2 > y._2
      else false
    }

    val T = (A.sortWith(compare)).distinct

    val size = T.size
    var cnt = A.count(_ == T(0)) //I = numarul de locuri pe care le impart cei de pe pozitia total + 1
    var total = 0 // I = numarul de locuri deja ocupate
    var index = 1
    var oldcnt = 0
    while(total < k && index < size) {
      total += cnt
      oldcnt = cnt
      cnt = A.count(_ == T(index))
      index += 1
    }
    // total >= k
    if(total < k) println(cnt)
    else println(oldcnt)
  }
}


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

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

  val Array(n, k) = readInts

  def ans = (for(_ <- 1 to n) yield readInts).map {
    case Array(f, t) => f - 0.max(t - k)
  }.max

  def main(a: Array[String]) {
    println(ans)
  }
}

import java.util.StringTokenizer

object _276A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val k = next.toInt
  val a = (1 to n).map(i => { val f = next.toInt; val t = next.toInt; if (t <= k) f else f - (t - k) })
  println(a.max)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  println(Range(0, n).map{_ =>
    val d = in.next().split(" ").map(_.toInt)
    if (d(1) > k) d(0) - (d(1) - k)
    else d(0)
  }.max)
}

object A276 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val in = Array.fill(n)(readInts(2))

    var max = Int.MinValue
    for(i <- 0 until n) {
      if(in(i)(1) > k) {
        max = math.max(max, in(i)(0) - (in(i)(1) - k))
      } else {
        max = math.max(max, in(i)(0))
      }
    }
    println(max)
  }

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

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

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

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

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

}

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

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

  val n, k = sc.nextInt

  val answer = {
    List.fill(n) {
      val f, t = sc.nextInt
      if (t <= k) f
      else f + k - t
    }
  }.max

  out.println(answer)
  out.close
}

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

    val Array(n,k) = readLine().split(" ").map(_.toInt)
    var m = Integer.MIN_VALUE;
    for (i <- 1 to n) {
      val Array(f,t) = readLine().split(" ").map(_.toInt)
      m = math.max(m, f-math.max(0, t-k))
    }
  println(m)
  }
}

import java.util.Scanner

object Main {

    val input = new Scanner(System.in)

    def main(args: Array[String]) {
        val n = input.nextInt
        val k = input.nextInt
        val it = new MyIt().take(n).map {
            case (f, t) => if (t > k) f - (t - k) else f
        }
        println(it.max)
    }

    class MyIt extends Iterator[(Int, Int)] {
        def hasNext = true
        def next : (Int, Int) = {
            val a = input.nextInt
            val b = input.nextInt
            (a, b)
        }
    }
}

object Main {
  def main(args: Array[String]) {
    val nk = readLine().split(" ").map(_.toInt)
    val k = nk(1)
    val pl = (1 to nk(0)).map{ _ =>
      val a = readLine().split(" ").map(_.toInt)
      if (a(1) > k) a(0) - a(1) + k
      else a(0)
    }
    println(pl.max)
  }
}

object A {

	def main(args: Array[String]) {
		val nk = Console.readLine.split(" ").map(_.toInt)
		val n = nk(0)
		val k = nk(1)

		def ud(f: Int, t: Int) = if(t > k) f - (t - k) else f

		var result = (for(i <- 0 until n) yield {
			val ft = Console.readLine.split(" ").map(_.toInt)
			ud(ft(0), ft(1))
		})
		println(result.max)
	}
}

object A {

	def main(args: Array[String]) {
		val nk = Console.readLine.split(" ").map(_.toInt)
		val n = nk(0)
		val k = nk(1)

		def ud(f: Int, t: Int) = if(t > k) f - (t - k) else f

		var mf = -1
		for(i <- 0 until n) {
			val ft = Console.readLine.split(" ").map(_.toInt)
			mf = math.max(mf, ud(ft(0), ft(1)))
		}
		println(mf)
	}
}


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

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

    val ans = bn.sum > 0 && bn.sum < bn.length || (an, an.tail).zipped.forall(_ <= _)

    if (ans) println("Yes")
    else println("No")
  }
}

import scala.io.StdIn.readLine

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

  def main(args: Array[String]): Unit = {
    //    val src = io.Source.fromFile("/usr/share/dict/words")
    //    val lines = src.getLines()
    //    src.close()
    val t = readLine().toInt
    for (i <- 1 to t) {
      val n = readLine()
      val values = readIntLine()
      val types = readIntLine()
      println(if (types.distinct.size > 1 || values.sorted.equals(values)) "Yes" else "No")
    }
  }

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

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

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

}

import java.util

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

  for (_ <- 1 to nextInt) {
    val n = nextInt
    val as, bs = nextInts(n)
    val can = bs.distinct.size > 1 || util.Arrays.equals(as, as.sorted)

    out.println(if (can) "Yes" else "No")

    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 ProblemB extends App {

  import java.io.{BufferedReader, InputStreamReader, PrintWriter}
  import java.util.StringTokenizer
  import scala.collection.mutable

  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))
  val out = new PrintWriter(System.out)

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

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

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

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

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

  val t = in.nextInt()

  for (_ <- 1 to t) {
    val n = in.nextInt()
    var a = new Array[Int](n)
    var b = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = in.nextInt()
    }
    var hasFirstType = false
    var hasSecondType = false
    for (i <- 0 until n) {
      b(i) = in.nextInt()
      if (b(i) == 0) {
        hasFirstType = true
      } else {
        hasSecondType= true
      }
    }

    val aCopy = a.clone
      java.util.Arrays.sort(aCopy)
    val res = if (a.sameElements(aCopy) || (hasFirstType && hasSecondType)) {
      "yes"
    } else {
      "no"
    }

    println(res)
  }

}


object Main {

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

  import scala.collection.mutable
  import scala.collection.mutable.ListBuffer
  def main(args: Array[String]): Unit = {
    solve(System.in,System.out)
  }

  def solve(inputStream: InputStream, out: PrintStream): Unit = {
    val in = new InputReader(inputStream)
    val t = in.nextInt()

    def printEnd(k: Int): Unit = {
      out.print('b')
      out.print((1 until k).map(_ => 'a').mkString(""))
    }
    def printBeg(k: Int): Unit = {

      out.print((1 until k).map(_ => 'a').mkString(""))
      out.print('b')
    }
    def printMiddle(k: Int): Unit = {
      out.print((1 to k).map(_ => 'a').mkString(""))
    }

    (1 to t).foreach{ _ =>
      val n = in.nextLong()
      val k = in.nextLong()
      val z = ((Math.sqrt(8d*k+1)-1d)/2d).toLong
      val rowsUsed: Long = if((z*(z-1))/2 >= k) z-1 else  z
      val suma = (rowsUsed*(rowsUsed+1))/2
      val resta = k - suma
      //println(s"n: $n k:$k z:$z resta:$resta rowsUsed:$rowsUsed")

      if(resta!=0) {
        printBeg((n - rowsUsed - 1).toInt)
        printMiddle((rowsUsed - resta +1).toInt)
        printEnd(resta.toInt)
      }else{
        printBeg((n - rowsUsed).toInt)
        printEnd(rowsUsed.toInt)
      }
      out.println("")

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

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

  val t = nextInt

  for (_ <- 1 to t) {
    val n, k = nextInt
    var i = 1
    var cnt = 0
    while (cnt + i < k) {
      cnt += i
      i += 1
    }
    var j = k - cnt
    var s = Array.fill(n)('a')
    s(n - i - 1) = 'b'
    s(n - j) = 'b'
    out.println(s.mkString)
  }

  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._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.collection.mutable.ListBuffer
  def main(args: Array[String]): Unit = {
    solve(System.in,System.out)
  }

  def solve(inputStream: InputStream, out: PrintStream): Unit = {
    val in = new InputReader(inputStream)
    val t = in.nextInt()

    def printEnd(k: Int): Unit = {
      out.print('b')
      out.print((1 until k).map(_ => 'a').mkString(""))
    }
    def printBeg(k: Int): Unit = {

      out.print((1 until k).map(_ => 'a').mkString(""))
      out.print('b')
    }
    def printMiddle(k: Int): Unit = {
      out.print((1 to k).map(_ => 'a').mkString(""))
    }

    (1 to t).foreach{ _ =>
      val n = in.nextInt()
      val k = in.nextInt()
      val z = ((Math.sqrt(8d*k+1)-1d)/2d).toInt
      val rowsUsed = if((z*(z-1))/2 >= k) z-1 else  z
      val suma = (rowsUsed*(rowsUsed+1))/2
      val resta = k - suma
      //println(s"n: $n k:$k z:$z resta:$resta rowsUsed:$rowsUsed")

      if(resta!=0) {
        printBeg(n - rowsUsed - 1)
        printMiddle(rowsUsed - resta +1)
        printEnd(resta)
      }else{
        printBeg(n - rowsUsed)
        printEnd(rowsUsed)
      }
      out.println("")

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


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

  override def apply(io: IO): io.type = {
    val q = io.read[Int]
    val ans = (1 to q) map {_ =>
      val n, k = io.read[Int]
      val as = io.read[Seq, Long](n)
      var lower = Long.MinValue
      var upper = Long.MaxValue

      try {
        for {
          a <- as
          x = a + k
          y = a - k
        } {
          require(y <= upper && x >= lower)
          lower = lower max y
          upper = upper min x
        }
        upper
      } catch {
        case _: Throwable => -1
      }
    }

    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 EqualizePrice {
  def main(args: Array[String]): Unit = {
    val q = StdIn.readInt()
    for (qi <- 1 to q) {
      val nk = StdIn.readLine().split(' ')
      val n = nk(0).toInt
      val k = nk(1).toInt
      val as = StdIn.readLine().split(' ').map(_.toInt)
      val ans = as.map(_ + k).min
      val isErr = as.exists{a: Int =>
        Math.abs(ans - a) > k
      }
      if (qi == q) if (isErr) print(-1) else print(ans)
      else if (isErr) println(-1) else println(ans)

    }
  }
}