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

import scala.collection.mutable

object A {

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

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

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

  def nextInt: Int = Integer.parseInt(next)

  def nextBoolean: Boolean = next.equalsIgnoreCase("1")

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

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

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

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

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

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

    override def toString = s"MultiHashSet($map)"
  }

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

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

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

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

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

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

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

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

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

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

    def query(p: Int) = ???

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

  def solve: Unit = {
    val t = nextInt
    for (_ <- 0 until t) {
      val n = nextInt
      val arr = new Array[Int](n)
      for (i <- 0 until n) {
        arr(i) = nextInt

      }
      val sorted = arr.sorted
      var flag = true
      for (i <- 1 until n) {
        if (sorted(i) - sorted(i - 1) > 1)
          flag = false
      }
      if (flag) {
        out.println("YES")
      } else {
        out.println("NO")
      }

    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 1 to t) {
      val _ = StdIn.readLine().trim.toInt
      val arr = StdIn.readLine().split(" ").map(_.toInt).toList.sorted
      val flag = (arr.head :: arr).zip(arr).forall(p => math.abs(p._1 - p._2) <= 1)
      if (flag) println("YES") else println("NO")
    }
  }
}

import scala.io.Source
// http://codeforces.com/problemset/problem/1399/A
object RemoveSmallest1399A extends App {
  val lines: Iterator[String] = Source.fromInputStream(System.in).getLines
//  val lines: Iterator[String] =
//    Source.fromString("5\n3\n1 2 2\n4\n5 5 5 5\n3\n1 2 4\n4\n1 3 4 4\n1\n100").getLines
  val ntc: Int = lines.next.toInt
  0 until ntc map { _ =>
    handleTC()
  } foreach println

  def handleTC() = {
    if (lines.next.toInt == 1) {
      lines.next
      "YES"
    } else {
      val ints = lines.next.split(" ").map(_.toInt)
      if (solve(ints)) "YES" else "NO"
    }
  }

  def solve(inAr: Array[Int]) = {
    val s = inAr.sorted
    s.zip(s.tail).forall { case (i, j) =>
      j - i <= 1
    }
  }
}

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

  override def solve(io: IO) = io.repeat {
    val as = io.read[Seq[Int]].sorted
    val ans = as.sliding(2) forall {
      case Seq(a, b) => (b - a) <= 1
      case _ => true
    }
    io.write(ans.toEnglish.toUpperCase)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

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

  def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None

  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)

  val charToInt: Char => Int = Character.getNumericValue
  val intToChar: Int => Char = Character.forDigit(_, 10)

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

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

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

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

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

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

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

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

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }

  implicit class IntExtensions(val x: Int) extends AnyVal {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

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

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }

  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]

  def memoize[A, B](f: A => B): A => B = map[A] using f
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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

//package codeforces.contests._1399

object RemoveSmallest {

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

      val doFollow = arr.foldLeft((true, arr.head)) { case ((acc, prev), e) => if (acc) (e - prev <= 1, e) else (false, e) }._1

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

}

import scala.concurrent.duration.DurationInt
import scala.concurrent._
import scala.io.Source
// http://codeforces.com/problemset/problem/1399/A
object RemoveSmallest1399A extends App {
  val lines: Iterator[String] = Source.fromInputStream(System.in).getLines
//  val lines: Iterator[String] =
//    Source.fromString("5\n3\n1 2 2\n4\n5 5 5 5\n3\n1 2 4\n4\n1 3 4 4\n1\n100").getLines
  val ntc: Int = lines.next.toInt
  implicit val global: ExecutionContextExecutor = ExecutionContext.global
  val resSeq: Seq[Future[String]] = 0 until ntc map { _ =>
    handleTC()
  }
  Await.result(Future.sequence(resSeq), 100.second).foreach(println)

  def handleTC(): Future[String] = {
    val al = lines.next.toInt
    val ints = lines.next.split(" ").map(_.toInt)
    Future {
      if (ints.length == 1) ("YES")
      else {
        if (solve(ints).isDefined) ("YES") else ("NO")
      }
    }
  }

  def solve(inAr: Array[Int]): Option[Array[Int]] = {
    if (inAr.length == 1) Some(inAr)
    else children(inAr).flatMap(solve).headOption
  }

  def children(inAr: Array[Int]): Stream[Array[Int]] = {
    def removeElementAt(arr: Array[Int], ind: Int) =
      arr.zipWithIndex.filterNot { case (_, in) => in == ind }.map(_._1)

    (0 until inAr.length - 1).toStream
      .zip((1 until inAr.length).toStream).flatMap { case (i, j: Int) =>
      println(s"$i, $j")
      if (inAr(i) - inAr(j) == 1) Array(removeElementAt(inAr, j))
      else if (inAr(i) - inAr(j) == -1) Array(removeElementAt(inAr, i))
      else if (inAr(i) - inAr(j) == 0) Array(
        removeElementAt(inAr, i),
        removeElementAt(inAr, j)
      )
      else Array[Array[Int]]()
    }
  }

}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 1 to t) {
      val _ = StdIn.readLine().trim.toInt
      val arr = StdIn.readLine().split(" ").map(_.toInt).toList
      val flag = (arr.head :: arr).zip(arr).forall(p => math.abs(p._1 - p._2) <= 1)
      if (flag) println("YES") else println("NO")
    }
  }
}


import java.util.Scanner

object FindExtraOne {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val xs = for (i <- 0.until(N); (x, y) = (sc.nextInt(), sc.nextInt())) yield x

    val xsPartitions = xs.partition(_ > 0)
    val exists = xsPartitions._1.length <= 1 || xsPartitions._2.length <= 1

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

object a900 {
  def main(args: Array[String]): Unit = {
    val (a, b) = scala.io.Source.stdin.getLines() drop 1 map (_ split (" ") map (_.toInt)) partition (_ (0) < 0)
    println(
      (a.length, b.length) match {
        case (0, _) | (_, 0) | (1, _) | (_, 1) => "Yes"
        case _ => "No"
      }
    )
  }
}

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

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

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

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

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

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

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

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

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

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

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


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

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new C640B(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

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

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

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

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

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

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

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

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

class C640B(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val t = ni()
    REP(t) { _ =>
      val n = ni()
      val k = ni()

      if(n % 2 == 0) {
        if(k % 2 != 0) {
          val x = 2 * (k - 1)
          if(x >= n) {
            out.println("NO")
          } else {
            out.println("YES")
            0 until (k-1) foreach (_ => out.print("2 "))
            out.println(n-x)
          }
        } else {
          val x = k-1
          if(x >= n) {
            out.println("NO")
          } else {
            out.println("YES")
            0 until (k-1) foreach (_ => out.print("1 "))
            out.println(n-x)
          }
        }
      } else {
        if(k % 2 == 0) {
          out.println("NO")
        } else {
          val x = k - 1
          if(x >= n) {
            out.println("NO")
          } else {
            out.println("YES")
            0 until (k-1) foreach (_ => out.print("1 "))
            out.println(n-x)
          }
        }
      }
    }
  }
}

object B extends App {

  private def summands(n: Int, k: Int): List[List[Int]] =
    List(1, 2)
      .map(r => (r, n - r * (k - 1)))
      .collect {
        case (r, d) if d > 0 && d % 2 == r % 2 => d :: List.fill(k - 1)(r)
      }

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

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

    val ak = summands(n, k)

    if (ak.isEmpty) println("NO")
    else {
      println("YES")
      println(ak.head.mkString(" "))
    }
  }
}

object B extends App {
  private def summands(n: Int, k: Int): List[List[Int]] =
    List(1, 2).map(r => (r, n - r * (k - 1))).collect {
      case (r, d) if d > 0 && d % 2 == r % 2 => d :: List.fill(k - 1)(r)
    }

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

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

    val ak = summands(n, k)

    if (ak.isEmpty) println("NO")
    else {
      println("YES")
      println(ak.head.mkString(" "))
    }
  }
}

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

  override def solve(io: IO) = io.repeat {
    val n, k = io.read[Int]

    val ans = for {
      member <- Seq(1, 2)
      residue = n - member*(k - 1)
      if residue > 0 && residue%2 == member%2
    } yield Seq.fill(k-1)(member) :+ residue

    ans.headOption match {
      case Some(seq) => io.writeLine("YES").writeAll(seq)
      case _ => io.writeLine("NO")
    }
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

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

  def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None

  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)

  val charToInt: Char => Int = Character.getNumericValue
  val intToChar: Int => Char = Character.forDigit(_, 10)

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

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

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

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

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

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

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

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

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }

  implicit class IntExtensions(val x: Int) extends AnyVal {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

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

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }

  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]

  def memoize[A, B](f: A => B): A => B = map[A] using f
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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

object 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 n = in.nextInt()

  def solve(n: Integer, k: Integer): Unit = {
    val result: List[Int] = {
      if (n % 2 == 0 && k % 2 == 1) {
        (n - (k - 1) * 2) :: (1 until k).map(_ => 2).toList
      } else if ((n % 2 == 1 && k % 2 == 1) || (n % 2 == 0)) {
        (n - (k - 1)) :: ((1 until k).map(_ => 1)).toList
      } else {
        List(-1)
      }
    }

    if (result.head <= 0) {
      println("NO")
    } else {
      println("YES")
      println(result.mkString(" "))
    }
  }

  for (i <- 1 to n) {
    val n = in.nextInt()
    val k = in.nextInt()

    solve(n, k)
  }

}

import scala.io.StdIn

object B {

   def solution(n: Int, k: Int): Option[Seq[Int]] = {
     lazy val with1 = Some((n - 1 * (k - 1)) +: Seq.fill(k - 1)(1))
       .filter(_.head > 0)
       .filter(_.head % 2 == 1)
     lazy val with2 = Some((n - 2 * (k - 1)) +: Seq.fill(k - 1)(2))
       .filter(_.head > 0)
       .filter(_.head % 2 == 0)
     with1.orElse(with2)
   }

   def main(args: Array[String]): Unit = {
      for (_ <- (0 until StdIn.readLine.toInt)) {
         val Seq(n, k) = StdIn.readLine.split(" ").toSeq.map(_.toInt)
         solution(n, k) match {
            case Some(seq) =>
             println("YES")
             println(seq.mkString(" "))
            case None =>
             println("NO")
         }
      }
   }
}

object B extends App {

  private def summands(n: Int, k: Int): List[List[Int]] =
    List(1, 2)
      .map(r => (r, n - r * (k - 1)))
      .collect {
        case (r, d) if d % 2 == r % 2 => d :: List.fill(k - 1)(r)
      }

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

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

    val ak = summands(n, k)

    if (ak.isEmpty) println("NO")
    else {
      println("YES")
      println(ak.head.mkString(" "))
    }
  }
}

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 n = in.nextInt()

  def solve(n: Integer, k: Integer): Unit = {
    val result: List[Int] = {
      if (n % 2 == 0 && k % 2 == 1) {
        (n - (k - 1) * 2) :: (1 until k).map(_ => 2).toList
      } else if ((n % 2 == 1 && k % 2 == 1) || (n % 2 == 0)) {
        (n - (k - 1)) :: ((1 until k).map(_ => 1)).toList
      } else {
        List(-1)
      }
    }

    if (result.head < 0) {
      println("NO")
    } else {
      println("YES")
      println(result.mkString(" "))
    }
  }

  for (i <- 1 to n) {
    val n = in.nextInt()
    val k = in.nextInt()

    solve(n, k)
  }

}


import scala.io.StdIn

/**
  * Created by Aleksei Latyshev on 04.03.2017.
  */
object D extends App {
  val Array(n, k) = StdIn.readLine().split(" ").map(_.toInt)
  val a = Array.ofDim[Int](1 << 14 + 1)
  StdIn.readLine().split(" ").map(_.toInt).foreach(x => a(x) += 1)
  if (k != 0) {
    val b: Seq[Int] = (1 until (1 << 14)).filter(x => Integer.bitCount(x) == k)
    println(a.take(10001).zipWithIndex.map {
      case (c, x) => b.map(y => a(y ^ x)).sum.toLong * c
    }.sum / 2)
  } else {
    println(a.map(x => x.toLong * (x - 1) / 2).sum)
  }
}

import scala.collection.mutable.ListBuffer
import scala.util.Random

/**
  * Created by netman on 3/4/17.
  */
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.fromInputStream(System.in).getLines().toArray
    val Array(n, k) = lines(0).split(" ").map(_.toInt)
    val MaxValue = 1 << 14
    val cntBits = Array.ofDim[Int](MaxValue)
    for (i <- 1 until MaxValue) {
      cntBits(i) = cntBits(i >> 1) + (i & 1)
    }
    val rnd = new Random
    val arr = lines(1).split(" ").map(_.toInt)
    val cnt = Array.ofDim[Int](MaxValue)
    arr.foreach(cnt(_) += 1)
    if (k == 0) {
      var res = 0L
      for (i <- cnt.indices) {
        res += (cnt(i).toLong * (cnt(i) - 1).toLong) / 2
      }
      println(res)
    } else {
      val tmp = ListBuffer.empty[Int]
      for (mask <- cntBits.indices) {
        if (cntBits(mask) == k) tmp += mask
      }
      val lst = tmp.toArray
      var res = 0L
      for (mask <- cnt.indices) {
        if (cnt(mask) != 0) {
          for (other <- lst) {
            res += cnt(mask ^ other).toLong * cnt(mask).toLong
          }
        }
      }
      println(res / 2)
    }
  }
}

import scala.collection.mutable.ListBuffer

/**
  * Created by netman on 3/4/17.
  */
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.fromInputStream(System.in).getLines().toArray
    val Array(n, k) = lines(0).split(" ").map(_.toInt)
    val MaxValue = 1 << 14
    val cntBits = Array.ofDim[Int](MaxValue)
    for (i <- 1 until MaxValue) {
      cntBits(i) = cntBits(i >> 1) + (i & 1)
    }
    val arr = lines(1).split(" ").map(_.toInt)
    val cnt = Array.ofDim[Int](MaxValue)
    arr.foreach(cnt(_) += 1)
    if (k == 0) {
      var res = 0L
      for (i <- cnt.indices) {
        res += (cnt(i).toLong * (cnt(i) - 1)) / 2
      }
      println(res)
    } else {
      val tmp = ListBuffer.empty[Int]
      for (mask <- cntBits.indices) {
        if (cntBits(mask) == k) tmp += mask
      }
      val lst = tmp.toArray
      var res = 0L
      for (mask <- cnt.indices) {
        if (cnt(mask) != 0) {
          for (other <- lst) {
            res += cnt(mask ^ other)
          }
        }
      }
      println(res / 2)
    }
  }
}


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

  lazy val xn: Stream[Int] = Stream.iterate(1)(_ + 1).filterNot(x => x % 3 == 0 || (x % 10) == 3)

  val t = readInt()

  (0 until t).foreach { _ =>
    val k = readInt()

    val ans = xn(k - 1)

    println(ans)
  }
}

import java.io._
import java.util.Scanner
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import util.control.Breaks._

object Solution {
    val reader = new Scanner(System.in)
    val writer =  new PrintWriter(System.out)

    def pow(a: Int, b: Int): Long = {
        if (b == 0) return 1

        val rs = pow(a, b / 2)
        rs * rs * (if (b % 2 == 0) 1 else a)
    }

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

    def LCM(a: Int, b: Int): Int = (a / GCD(a,b)) * b

    def root(u: Int, p: Array[Int]): Int = {
        if (p(u) < 0) return u
        p(u) = root(p(u), p)
        p(u)
    }

    def join(u: Int, v: Int, p: Array[Int]): Unit = {
        var x = root(u, p)
        var y = root(v, p)
        if (x == y) return

        if (p(y) < p(x)) {
            val t = x
            x = y
            y = t
        }
        p(x) += p(y)
        p(y) = x
    }

    def solve(t: Int = 0): Unit = {
        val n = reader.nextInt()
        var i = 0
        var k = 1L
        while (true) {
            if (k % 3 != 0 && k % 10 != 3) {
                i += 1
                if (i == n) {
                    writer.println(k)
                    return
                }
            }
            k += 1
        }
    }

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

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


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val names = (1 to n).map(_ => in.next())

  def next(str: String) = {
    if (str.forall(_ == 'z'))
      "a" * (str.length + 1)
    else {
      val postfix = str.reverse.takeWhile(_ == 'z').reverse
      val increment = str(str.length - postfix.length - 1)
      str.take(str.length - 1 - postfix.length) + (increment + 1).toChar + "a" * postfix.length
    }
  }

  def isNew(str: String) = {
    !names.exists(_.contains(str))
  }
  var candidate = "a"

  while (!isNew(candidate)) candidate = next(candidate)
  println(candidate)
}

object Main {
  val chars = "abcdefghijklmnopqrstuvwxyz".map(_.toString)

  def main(args: Array[String]) {
    val n = readInt()
    val a = for(_ <- 1 to n) yield { readLine() }
    val str = (chars ++ chars.flatMap(c => chars.map(c + _))).find(s => a.find(_.contains(s)).isEmpty)
    println(str.get)
  }
}


import java.io._
import java.util.StringTokenizer
import scala.+:
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object Main extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class fenwick(n: Int) {
        val tree = new Array[Long](n+1)
        def query(ind: Int): Long = {
            var idx = ind
            var ans = 0L
            while (idx > 0) {
                ans += tree(idx)
                idx -= (idx & -idx)
            }
            return ans
        }
        def update(ind: Int, value: Long): Unit = {
            var idx = ind
            while (idx <= n) {
                tree(idx) += value
                idx += (idx & -idx)
            }
        }
    }

    case class pair(var value: Int, var ind:  Int)extends Ordered[pair] {
        override def compare(that: pair): Int = {
            return value.compareTo(that.value)
        }
    }

    val rem = 1000000007
    def gcd(a: Int, b: Int): Int = b match {
        case 0 => a
        case n => gcd(b, a % b)
    }

    val t = readInt()
    for (tt <- 1 to t) {
        val keys = readString()
        val ind = mutable.Map[Char, Int]()
        val s = readString()
        for (i <- keys.indices) {
            ind(keys(i)) = i
        }
        var ans = 0
        for (i <- 1 until s.length) {
            ans += abs(ind(s(i)) - ind(s(i-1)))
        }
        writer.println(ans)
    }
    writer.flush()
}

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

  override def solve(io: IO) = {
    val inputs = io.read[Seq[(String, String)]]
    inputs foreach { case (_keyboard, target) =>
      val keyboard = _keyboard.toVector
      val ans = target.map(keyboard.indexOf(_))
        .sliding(2)
        .map({
          case Seq(a, b) => (a - b).abs
          case _ => 0
        })
        .sum
      io.writeLine(ans)
    }
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

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

  def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None

  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)

  val charToInt: Char => Int = Character.getNumericValue
  val intToChar: Int => Char = Character.forDigit(_, 10)

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

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

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

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

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

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

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

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

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }

  implicit class IntExtensions(val x: Int) extends AnyVal {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

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

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }

  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]

  def memoize[A, B](f: A => B): A => B = map[A] using f
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

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

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

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

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

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

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

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

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


object B {
  def main(args: Array[String]) {
    var s = readLine()
    var opened = false;
    var arr:Array[Char] = s.toCharArray
    for (i <- 0 until s.length) {
      if (arr(i) == '\"') opened = !opened;
      if (arr(i) == ' ' && !opened)  arr(i) = '#';
    }
    new String(arr).split("#") filter (!_.isEmpty) foreach {ss => println("<" + ss.replaceAll("\"", "") + ">" )}
  }
}

object B {
  def main(args: Array[String]) {
    val s = readLine()
    var inside = false
    var token = ""
    for (x <- s) {
      if (inside) {
        if (x == '\"') {
          println("<" + token + ">")
          token = ""
          inside = false
        } else {
          token += x
        }
      } else {
        if (x == '\"') {
          inside = true
        } else if (x == ' ') {
          if (token != "") {
            println("<" + token + ">")
          }
          token = ""
        } else {
          token += x
        }
      }
    }
    if (token != "") {
      println("<" + token + ">")
    }
  }
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val (list, _, soFar) = in.next().foldLeft(List.empty[String], false, List.empty[Char]) {
    case ((list, true, soFar), '"') => (soFar.reverse.mkString :: list, false, List.empty[Char])
    case ((list, true, soFar), ch) => (list, true, ch :: soFar)
    case ((list, false, Nil), '"') => (list, true, List.empty[Char])
    case (acc@(list, false, Nil), ' ') => acc
    case (acc@(list, false, something), ' ') => (something.reverse.mkString :: list, false, List.empty[Char])
    case (acc@(list, false, something), ch) => (list, false, ch :: something)
  }

  val res = if (soFar.nonEmpty) soFar.reverse.mkString :: list else list

  println(res.reverse.map(i => s"<$i>").mkString("\n"))

}

/*
B. Аргументы командной строки
ограничение по времени на тест
2 секунды
ограничение по памяти на тест
256 мегабайт
ввод
standard input
вывод
standard output

В данной задаче используется описание свойств командной строки, близкое к тому, что вы привыкли видеть в настоящих операционных системах. Однако, в деталях существуют отличия в поведении. Внимательно прочтите условие, используйте его как формальный документ при разработке решения.

В операционной системе Pindows лексемами командной строки являются строки — первая из них трактуется как имя запускаемой программы, а последующие как ее аргументы. Например, выполняя команду « run.exe one, two . », мы передаем командной строке Pindows четыре лексемы: «run.exe», «one,», «two», «.». Более формально, если мы выполняем команду, которая представима строкой s (и не содержит кавычек), то лексемами командной строки являются максимальные по включению подстроки строки s, которые не содержат пробелов.

Для того, чтобы передать в качестве лексемы командной строки строку с пробелами или пустую строку, используются двойные кавычки. Блок символов, который должен рассматриваться как одна лексема, берется в кавычки. При этом вложенные кавычки запрещаются — то есть про каждое вхождение символа «"» можно однозначно сказать — что это, открывающие кавычки или закрывающие. Например, выполняя команду «"run.exe o" "" " ne, " two . " " », мы передаем командной строке Pindows шесть лексем: «run.exe o», «» (пустая строка), « ne, », «two», «.», « » (единичный пробел).

Гарантируется, что каждая из лексем командной строки окружена с обеих сторон пробелами или упирается в соответствующий край командной строки. Из этого, например, следует, что открывающие кавычки либо являются первым символом строки, либо слева от них находится пробел.

Вам задана строка, состоящая из прописных, строчных букв латинского алфавита, цифр, символов «.,?!"» и пробелов. Гарантируется, что эта строка — корректная командная строка OS Pindows. Выведите все лексемы этой командной строки. Считайте, что символ «"» используется в команде только для выделения единого блока символов в одну лексему командной строки, в частности, из этого следует, что таких символов в заданной строке четное количество.
Входные данные

В единственной строке задана непустая строка s. Строка s состоит из не более чем 105 символов. Каждый символ — это либо прописная, либо строчная буква латинского алфавита, либо цифра, либо один из символов «.,?!"», либо пробел.

Гарантируется, что заданная строка — некоторая корректная командная строка OS Pindows. Гарантируется, что в заданной командной строке есть хотя бы одна лексема.
Выходные данные

В первой строке выведите первую лексему, во второй строке — вторую, и так далее. Для наглядности слева от каждой лексемы выведите символ «<» (меньше), а справа — символ «>» (больше). Выводите лексемы в том порядке, в котором они встречаются в команде.

Строго следуйте описанному формату вывода. Для лучшего понимания формата вывода посмотрите тестовые примеры.
Примеры тестов
Входные данные

"RUn.exe O" "" "   2ne, " two! . " "

Выходные данные

<RUn.exe O>
<>
<   2ne, >
<two!>
<.>
< >

Входные данные

   firstarg   second   ""

Выходные данные

<firstarg>
<second>
<>
 */
import scala.collection.JavaConversions._

object Task2 extends App {

  def clear(s: StringBuilder) = {
    s.clear
    s
  }

  def add(l: java.util.List[String], s: String) = {
    l add s
    l
  }
  /** Finds number of pairs, returns -1 if triplet or more */
  def solve(l: String): Seq[String] = {
    val acc = new java.util.ArrayList[String]
    def solveRec(s: String, i: Int, curr: StringBuilder, quoted: Boolean): Unit =
      if (i >= s.length) {
        assert(!quoted)
        if (!curr.isEmpty) add(acc, curr.toString)
      } else s(i) match {
        // Open quotes
        case '"' if !quoted                  => solveRec(s, i + 1, curr, true)
        // Add and close quotes
        case '"' if quoted                   =>  {
          add(acc, curr.toString)
          solveRec(s, i + 1, clear(curr), false)
        }
        // Ignore
        case ' ' if !quoted && curr.isEmpty  => solveRec(s, i + 1, curr, quoted)
        // Add and clear
        case ' ' if !quoted && !curr.isEmpty => {
          add(acc, curr.toString)
          solveRec(s, i + 1, clear(curr), quoted)
        }
        // Append
        case ' ' if quoted                   => solveRec(s, i + 1, curr += ' ', quoted)
        // Append
        case c                               => solveRec(s, i + 1, curr += c, quoted)
      }
    solveRec(l, 0, new StringBuilder, false)
    acc
  }

  val line = readLine
  val res = solve(line)
  res map (s => println("<" + s + ">"))
}

import io.Source
import java.io.PrintWriter

object CF291B {

  def solve(in: In, out: PrintWriter) {
    in.tokenIterator.toSeq.foreach { s => println("<" + s + ">") }
  }

  def main(args: Array[String]) {
    val in: In = new In(Source.fromInputStream(System.in))
    val out: PrintWriter = new PrintWriter(System.out)
    solve(in, out)
    out.close()
  }

  class TokenIterator(iter: BufferedIterator[Char], delims: String) extends Iterator[String] {
    private val sb = new StringBuilder

    def hasNext: Boolean = {
      skipDelims()
      iter.hasNext
    }

    def skipDelims() {
      while (iter.hasNext && delims.indexOf(iter.head) != -1) {
        iter.next()
      }
    }

    def next(): String = {
      skipDelims()
      var q = false
      var stop = false
      while (!stop && iter.hasNext && (q || delims.indexOf(iter.head) == -1)) {
        val c = iter.next()
        if (c == '"') {
          if (q) {
            stop = true
          } else {
            q = true
          }
        } else {
          sb.append(c)
        }
      }
      val ret = sb.toString()
      sb.clear()
      ret
    }
  }

  class In(source: Source) {
    val iter = source.buffered

    val tokenIterator = new TokenIterator(iter, " \r\n")

    val lineIterator = new TokenIterator(iter, "\r\n")

    def apply() = tokenIterator.next()

    def apply(n: Int) = tokenIterator.take(n)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine();
    var i = 0
    while(i < s.size) {
      if (s(i) == '"') {
        val j = s.indexOf('"', i + 1)
        println("<" + s.substring(i + 1, j) + ">")
        i = j + 2
      } else if (s(i) == ' ') {
        i += 1
      } else {
        val j = s.indexOf(' ', i + 1) match {
          case -1 => s.size
          case int: Int => int
        }
        println("<" + s.substring(i, j).trim + ">")
        i = j + 1
      }
    }
  }
}

object B {
  def main(args: Array[String]) {
    val s = readLine()
    var inside = false
    var token = ""
    for (x <- s) {
      if (inside) {
        if (x == '\"') {
          println("<" + token + ">")
          token = ""
          inside = false
        } else {
          token += x
        }
      } else {
        if (x == '\"') {
          inside = true
        } else if (x == ' ') {
          if (token != "") {
            println("<" + token + ">")
          }
          token = ""
        } else {
          token += x
        }
      }
    }
    if (token != "") {
      println(token)
    }
  }
}

import io.Source
import java.io.PrintWriter

object CF291B {

  def solve(in: In, out: PrintWriter) {
    in.tokenIterator.toSeq.foreach { s => println("<" + s + ">")}
  }

  def main(args: Array[String]) {
    val in: In = new In(Source.fromInputStream(System.in))
    val out: PrintWriter = new PrintWriter(System.out)
    solve(in, out)
    out.close()
  }

  class TokenIterator(iter: BufferedIterator[Char], delims: String) extends Iterator[String] {
    private val sb = new StringBuilder

    def hasNext: Boolean = {
      skipDelims()
      iter.hasNext && iter.head != '\n' && iter.head != '\r'
    }

    def skipDelims() {
      while (iter.hasNext && delims.indexOf(iter.head) != -1) {
        iter.next()
      }
    }

    def next(): String = {
      skipDelims()
      var q = false
      var stop = false
      while (!stop && iter.hasNext && (q || delims.indexOf(iter.head) == -1)) {
        val c = iter.next()
        if (c == '"') {
          if (q) {
            stop = true
          } else {
            q = true
          }
        } else {
          sb.append(c)
        }
      }
      val ret = sb.toString()
      sb.clear()
      ret
    }
  }

  class In(source: Source) {
    val iter = source.buffered

    val tokenIterator = new TokenIterator(iter, " ")

    val lineIterator = new TokenIterator(iter, "\r\n")

    def apply() = tokenIterator.next()

    def apply(n: Int) = tokenIterator.take(n)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine();
    var i = 0
    while(i < s.size) {
      if (s(i) == '"') {
        val j = s.indexOf('"', i + 1)
        println("<" + s.substring(i + 1, j) + ">")
        i = j + 2
      } else {
        val j = s.indexOf(' ', i + 1)
        if (j != i + 1) println("<" + s.substring(i, j).trim + ">")
        i = j + 1
      }
    }
  }
}


object FixingTypos extends App {
    val s = readLine

    def fix(str: String): String = {
        var ss: StringBuffer = new StringBuffer("")
        var now = 2
        for(i <- 0 until str.size if i==0 || str(i) != str(i-1)) {
            if(now == 2) ss.append(str(i))
            ss.append(str(i))
            now = 3 - now
        }
        ss.toString
    }

    var ret: StringBuffer = new StringBuffer("")
    var begin = 0
    for(i <- 0 until s.size) {
        var bb = false
        var ee = false
        if(i==0 || s(i) != s(i-1)) bb = true
        if(i== s.size - 1 || s(i) != s(i + 1)) ee = true
        if(ee && bb) {
            ret.append(fix(s.substring(begin, i)))
            ret.append(s(i))
            begin = i + 1
        } else if(i == s.size - 1) ret.append(fix(s.substring(begin, s.size)))
    }
    println(ret)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val str = in.next()
  val skipTriplets = str.tail.foldLeft((List(str.head), 1, str.head)) {
    case ((list, 2, prev), el) if prev == el => (list, 2, el)
    case ((list, count, prev), el) if prev == el =>
      (el :: list, count + 1, prev)
    case ((list, count, prev), el) =>
      (el :: list, 1, el)
  }._1.reverse
  val skip = skipTriplets.tail.foldLeft((List(str.head), false, str.head, 0)) {
    case((list, false, prev, n), el) if el == prev => (el :: list, true, el, 0)
    case((list, true, prev, 1), el) if el == prev => (list, false, el, 0)
    case((list, true, prev, 0), el) => (el :: list, true, el, 1)
    case((list, status, prev, n), el) => (el :: list, false, el, 0)
  }
  println(skip._1.reverse.mkString)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val str = in.next()
  val skipTriplets = str.tail.foldLeft((List(str.head), 1, str.head)) {
    case ((list, 2, prev), el) if prev == el => (list, 2, el)
    case ((list, count, prev), el) if prev == el =>
      (el :: list, count + 1, prev)
    case ((list, count, prev), el) =>
      (el :: list, 1, el)
  }._1.reverse
  val skip = skipTriplets.tail.foldLeft((List(str.head), false, str.head, 0)) {
    case((list, false, prev, n), el) if el == prev => (el :: list, true, el, 0)
    case((list, false, prev, n), el) => (el :: list, false, el, 0)
    case((list, true, prev, 1), el) if el == prev => (list, false, el, 0)
    case((list, true, prev, 0), el) if el == prev => (el :: list, true, el, 1)
    case((list, true, prev, n), el) => (el :: list, false, el, 0)
  }
  println(skip._1.reverse.mkString)
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val str = in.next()
  val skipTriplets = str.tail.foldLeft((List(str.head), 1, str.head)) {
    case ((list, 2, prev), el) if prev == el => (list, 2, el)
    case ((list, count, prev), el) if prev == el =>
      (el :: list, count + 1, prev)
    case ((list, count, prev), el) =>
      (el :: list, 1, el)
  }._1.reverse
  val skip = skipTriplets.tail.foldLeft((List(str.head), false, str.head, 0)) {
    case((list, false, prev, n), el) if el == prev => (el :: list, true, el, 0)
    case((list, false, prev, n), el) => (el :: list, false, el, 0)
    case((list, true, prev, 1), el) if el == prev => (list, false, el, 0)
    case((list, true, prev, 0), el) if el == prev => (el :: list, true, el, 1)
    case((list, true, prev, n), el) => (list, false, el, 0)
  }
  println(skip._1.reverse.mkString)
}


import scala.io.StdIn
import scala.math.min

object Main extends App {
  val n = StdIn.readInt()
  for (i <- 0 until n) {
    val values = StdIn.readLine().split(" ").map(_.toInt)
    val r = values(0)
    val b = values(1)
    val d = values(2)
    val delta = Math.abs(r - b)
    val minimal = min(r, b)
    println(if (Math.round(delta / minimal) + (if (delta % minimal == 0) 0 else 1) <= d) "YES" else "NO")
  }
}

object A {

  import java.io._

  val out: OutputPrinter = new StringOutputPrinter
  //val out: OutputPrinter = new OutputPrinter
  val input = new InputReader(new InputStreamReader(System.in))
//  val input = new InputReader(new StringReader(
//      """8
//1 1 0
//2 7 3
//6 1 4
//5 4 0
//1000000000 1000000000 0
//1000000000 1000000000 1000000000
//1000000000 1 1000000000
//1 1000000000 0
//          """))

  def main(args: Array[String]): Unit = {
    val startTime = System.currentTimeMillis()

    val executor = new Solution1
    executor.solve()

    out.flush()
    val elapsed = System.currentTimeMillis() - startTime
    //println(s"Elapsed: $elapsed")
  }

  class Solution1 {

    def solve(): Unit = {
      val tasks = input.nextInt
      for (_ <- 0 until tasks) {
        val r, b, d = input.nextInt
        val mn = r min b
        val mx = r max b
        val h = mx / (d + 1)
        val l = mx % (d + 1)
        if (mn > h || mn == h && l == 0 ) {
          out.print("YES")
        }
        else {
          out.print("NO")
        }
        out.endl()
      }
    }
  }

  // ===========================================================================
  // ---------  TOOLS  ---------------------------------------------------------
  // ===========================================================================

  class InputReader(reader: Reader) {

    import java.io.BufferedReader
    import java.util.StringTokenizer

    private val buffer = new BufferedReader(reader)
    private var parser: StringTokenizer = _

    private def next = {
      if (parser == null || !parser.hasMoreElements) {
        parser = new StringTokenizer(buffer.readLine)
      }
      parser.nextToken
    }

    def endl(): Unit = {
      parser = null
    }

    def nextByte = next.toByte

    def forBytes(num: Int)(op: (Int, Byte) => Unit): Unit = forr(num, nextByte, op)

    def nextInt = next.toInt

    def forInts(num: Int)(op: (Int, Int) => Unit): Unit = forr(num, nextInt, op)

    def nextLong = next.toLong

    def forLongs(num: Int)(op: (Int, Long) => Unit): Unit = forr(num, nextLong, op)

    def nextDouble = next.toDouble

    def forDoubled(num: Int)(op: (Int, Double) => Unit): Unit = forr(num, nextDouble, op)

    def nextString = next

    def forStrings(num: Int)(op: (Int, String) => Unit): Unit = forr(num, nextString, op)

    private def forr[T](num: Int, readOp: => T, op: (Int, T) => Unit): Unit = {
      for (index <- 0 until num) op(index, readOp)
    }
  }

  class OutputPrinter {
    private val buffer = new StringBuilder() // faster if exists

    def print(c: Char): Unit = {}

    def print(i: Int): Unit = {}

    def print(s: String): Unit = {}

    def endl(): Unit = {}

    def flush(): Unit = {}
  }

  class StringOutputPrinter(capacity: Int = 1024) extends OutputPrinter {
    private val buffer = new StringBuilder(capacity)

    override def print(c: Char): Unit = buffer.append(c)

    override def print(i: Int): Unit = buffer.append(i)

    override def print(s: String): Unit = buffer.append(s)

    override def endl(): Unit = buffer.append("\n")

    override def flush(): Unit = {
      println(buffer.result())
      buffer.clear()
    }
  }

}

object A {

  import java.io._

  val out: OutputPrinter = new StringOutputPrinter
  //val out: OutputPrinter = new OutputPrinter
  val input = new InputReader(new InputStreamReader(System.in))
//  val input = new InputReader(new StringReader(
//      """4
//1 1 0
//2 7 3
//6 1 4
//5 4 0
//          """))

  def main(args: Array[String]): Unit = {
    val startTime = System.currentTimeMillis()

    val executor = new Solution1
    executor.solve()

    out.flush()
    val elapsed = System.currentTimeMillis() - startTime
    //println(s"Elapsed: $elapsed")
  }

  class Solution1 {

    def solve(): Unit = {
      val tasks = input.nextInt
      for (_ <- 0 until tasks) {
        val r, b, d = input.nextInt
        val mn = r min b
        val mx = r max b
        val mx2 = mn * (d + 1)
        if (mx2 >= mx) {
          out.print("YES")
        }
        else {
          out.print("NO")
        }
        out.endl()
      }
    }
  }

  // ===========================================================================
  // ---------  TOOLS  ---------------------------------------------------------
  // ===========================================================================

  class InputReader(reader: Reader) {

    import java.io.BufferedReader
    import java.util.StringTokenizer

    private val buffer = new BufferedReader(reader)
    private var parser: StringTokenizer = _

    private def next = {
      if (parser == null || !parser.hasMoreElements) {
        parser = new StringTokenizer(buffer.readLine)
      }
      parser.nextToken
    }

    def endl(): Unit = {
      parser = null
    }

    def nextByte = next.toByte

    def forBytes(num: Int)(op: (Int, Byte) => Unit): Unit = forr(num, nextByte, op)

    def nextInt = next.toInt

    def forInts(num: Int)(op: (Int, Int) => Unit): Unit = forr(num, nextInt, op)

    def nextLong = next.toLong

    def forLongs(num: Int)(op: (Int, Long) => Unit): Unit = forr(num, nextLong, op)

    def nextDouble = next.toDouble

    def forDoubled(num: Int)(op: (Int, Double) => Unit): Unit = forr(num, nextDouble, op)

    def nextString = next

    def forStrings(num: Int)(op: (Int, String) => Unit): Unit = forr(num, nextString, op)

    private def forr[T](num: Int, readOp: => T, op: (Int, T) => Unit): Unit = {
      for (index <- 0 until num) op(index, readOp)
    }
  }

  class OutputPrinter {
    private val buffer = new StringBuilder() // faster if exists

    def print(c: Char): Unit = {}

    def print(i: Int): Unit = {}

    def print(s: String): Unit = {}

    def endl(): Unit = {}

    def flush(): Unit = {}
  }

  class StringOutputPrinter(capacity: Int = 1024) extends OutputPrinter {
    private val buffer = new StringBuilder(capacity)

    override def print(c: Char): Unit = buffer.append(c)

    override def print(i: Int): Unit = buffer.append(i)

    override def print(s: String): Unit = buffer.append(s)

    override def endl(): Unit = buffer.append("\n")

    override def flush(): Unit = {
      println(buffer.result())
      buffer.clear()
    }
  }

}


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

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

  // n rows
  // m cols

  val N, M = sc.nextInt
  val T = Array.fill(N, M)(sc.nextInt)

  var t = 0
  for (i <- 0 until M) {
    t += T(0)(i)
    t += T(N - 1)(i)
  }
  for (i <- 0 until N) {
    t += T(i)(0)
    t += T(i)(M - 1)
  }

  val answer = if (t > 0) 2
               else 4

  out.println(answer)
  out.close
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, m) = in.next().split(' ').map(_.toInt)
  val res = (1 to n).foldLeft(false) {
    case(true, _) => true
    case(false, 1) => in.next().split(' ').map(_.toInt).contains(1)
    case(false, i) if i == n => in.next().split(' ').map(_.toInt).contains(1)
    case(false, _) =>
      val data = in.next().split(' ').map(_.toInt)
      data.head == 1 || data.last == 1
  }
  if (res)
    println(2)
  else
    println(4)
}

object A359 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, m) = readInts(2)
    val a = Array.fill(n)(readInts(m))
    val ids = cu.ArrayBuffer.empty[(Int, Int)]
    for(i <- 0 until n; j <- 0 until m) {
      if(a(i)(j) == 1)
        ids.append((i, j))
    }
    if(a(0)(0) == 1 || a(0)(m-1) == 1 || a(n-1)(0) == 1 || a(n-1)(m-1) == 1)
      println("1")
    else if(ids.exists{case (x,y) => x==0 || x==n-1 || y==0 || y==m-1}) {
      println("2")
    } else {
      println("4")
    }
  }

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

    @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 Main {
  def main(args: Array[String]) {
    val nm = readLine().split(" ").map(_.toInt)
    val n = nm(0)
    val m = nm(1)
    val a = (1 to n).map(_ => readLine())

    val rows = a.head.find(_ == '1').isDefined || a.last.find(_ == '1').isDefined
    val cols = a.find(row => row.head == '1' || row.last == '1').isDefined

    if (rows || cols) println("2")
    else println("4")
  }
}


object A {
  def main(a: Array[String]) {
    def readArray = readLine.split(" ")
    val Array(n, m, k) = readArray.map(_.toInt)
    val initial = readArray.map(_.toLong)
    val operations = for (i <- 0 until m) yield readArray.map(_.toInt)
    val queries = for (i <- 0 until k) yield readArray.map(_.toInt)
    val opUsed = new Array[Long](m + 1)
    for (Array(qbegin, qend) <- queries) {
      opUsed(qbegin - 1) += 1
      opUsed(qend) -= 1
    }
    for (i <- 1 to m) opUsed(i) += opUsed(i - 1)
    val changes = new Array[Long](n + 1)
    for (i <- 0 until m) {
      val Array(from, to, d) = operations(i)
      val u = opUsed(i)
      changes(from - 1) += d * u
      changes(to) -= d * u
    }
    for (i <- 1 to n) changes(i) += changes(i - 1)
    val result = for (i <- 0 until n) yield initial(i) + changes(i)
    println(result.mkString(" "))
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, m, k) = in.next().split(' ').map(_.toInt)
  val data = in.next().split(' ').map(_.toInt)
  val increase = Array.ofDim[Long](n)
  val operations: Array[Int] = Array.ofDim[Int](m)
  val op = (1 to m).map { _ =>
    val Array(l, r, d) = in.next().split(' ').map(_.toInt)
    (l, r, d)
  }
  (1 to k).foreach { _ =>
    val Array(x, y) = in.next().split(' ').map(_.toInt - 1)
    operations(x) += 1
    if (y != m - 1)
      operations(y + 1) -= 1
  }
  operations.indices.foldLeft(0l) {
    case (balance, el) =>
      val (l, r, d) = op(el)
      val newBalance = balance + operations(el)
      increase(l - 1) += d * newBalance
      if (r != n)
        increase(r) -= d * newBalance
      newBalance
  }
  val r = increase.indices.foldLeft((0l, List.empty[Long])) {
    case ((open, list), i) =>
      val newBalance = open + increase(i)
      (newBalance, (newBalance + data(i)) :: list)
  }
  println(r._2.reverse.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, m, k) = in.next().split(' ').map(_.toInt)
  val data = in.next().split(' ').map(_.toInt)
  val increase = Array.ofDim[Int](n)
  val operations: Array[Int] = Array.ofDim[Int](m)
  val op = (1 to m).map { _ =>
    val Array(l, r, d) = in.next().split(' ').map(_.toInt)
    (l, r, d)
  }
  (1 to k).foreach { _ =>
    val Array(x, y) = in.next().split(' ').map(_.toInt - 1)
    operations(x) += 1
    if (y != m - 1)
      operations(y + 1) -= 1
  }
  operations.indices.foldLeft(0) {
    case (balance, el) =>
      val (l, r, d) = op(el)
      val newBalance = balance + operations(el)
      increase(l - 1) += d * newBalance
      if (r != n)
        increase(r) -= d * newBalance
      newBalance
  }
  val r = increase.indices.foldLeft((0, List.empty[Long])) {
    case ((open, list), i) =>
      val newBalance = open + increase(i)
      (newBalance, (newBalance + data(i)) :: list)
  }
  println(r._2.reverse.mkString(" "))
}

object A {
  def main(a: Array[String]) {
    def readArray = readLine.split(" ").map(_.toInt)
    val Array(n, m, k) = readArray
    val initial = readArray
    val operations = for (i <- 0 until m) yield readArray
    val queries = for (i <- 0 until k) yield readArray
    val opUsed = new Array[Int](m + 1)
    for (Array(qbegin, qend) <- queries) {
      opUsed(qbegin - 1) += 1
      opUsed(qend) -= 1
    }
    for (i <- 1 to m) opUsed(i) += opUsed(i - 1)
    val changes = new Array[Int](n + 1)
    for (i <- 0 until m) {
      val Array(from, to, d) = operations(i)
      val u = opUsed(i)
      changes(from - 1) += d * u
      changes(to) -= d * u
    }
    for (i <- 1 to n) changes(i) += changes(i - 1)
    val result = for (i <- 0 until n) yield initial(i) + changes(i)
    println(result.mkString(" "))
  }
}


object B {

  import InOut._

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

  val digits = Array(
    "1110111",
    "0010010",
    "1011101",
    "1011011",
    "0111010",
    "1101011",
    "1101111",
    "1010010",
    "1111111",
    "1111011"
  ).map(Integer.parseInt(_, 2))

  val n, k = nextInt
  val after = Array.fill(n)(Integer.parseInt(nextLine, 2))

  val dp = Array.fill(n + 1, k + 1)(-1)
  dp(n)(0) = 0
  for (i <- n - 1 to 0 by -1) {
    for (j <- 0 to k) {
      if (dp(i + 1)(j) != -1) {
        var d = 0
        while (d < 10) {
          if ((after(i) & digits(d)) == after(i)) {
            val need = Integer.bitCount(after(i) ^ digits(d))
            if (j + need <= k) {
              if (d > dp(i)(j + need)) dp(i)(j + need) = d
            }
          }
          d += 1
        }
      }
    }
  }

  if (dp(0)(k) == -1) {
    out.println(-1)
  } else {
    val res = Array.ofDim[Int](n)
    var j = k
    for (i <- 0 until n) {
      val d = dp(i)(j)
      res(i) = d
      j -= Integer.bitCount(after(i) ^ digits(d))
    }
    out.println(res.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 B {

  import InOut._

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

  val digits = Array(
    "1110111",
    "0010010",
    "1011101",
    "1011011",
    "0111010",
    "1101011",
    "1101111",
    "1010010",
    "1111111",
    "1111011"
  ).map(Integer.parseInt(_, 2))

  val n, k = nextInt
  val after = Array.fill(n)(Integer.parseInt(nextLine, 2))

  val dp = Array.fill(n + 1, k + 1)(-1)
  dp(n)(0) = 0
  for (i <- n - 1 to 0 by -1) {
    var j = 0
    while (j <= k) {
      if (dp(i + 1)(j) != -1) {
        var d = 0
        while (d < 10) {
          if ((after(i) & digits(d)) == after(i)) {
            val need = Integer.bitCount(after(i) ^ digits(d))
            if (j + need <= k) {
              if (d > dp(i)(j + need)) dp(i)(j + need) = d
            }
          }
          d += 1
        }
      }
      j += 1
    }
  }

  if (dp(0)(k) == -1) {
    out.println(-1)
  } else {
    val res = Array.ofDim[Int](n)
    var j = k
    for (i <- 0 until n) {
      val d = dp(i)(j)
      res(i) = d
      j -= Integer.bitCount(after(i) ^ digits(d))
    }
    out.println(res.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 B {

  import InOut._

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

  val digits = Array(
    "1110111",
    "0010010",
    "1011101",
    "1011011",
    "0111010",
    "1101011",
    "1101111",
    "1010010",
    "1111111",
    "1111011"
  ).map(Integer.parseInt(_, 2))

  val n, k = nextInt
  val after = Array.fill(n)(Integer.parseInt(nextLine, 2))

  var dp0 = Array.fill(k + 1)(-1)
  dp0(0) = 0
  for (i <- 0 until n) {
    val dp = Array.fill(k + 1)(-1)
    var j = 0
    while (j <= k) {
      if (dp0(j) >= -1) {
        var d = 0
        while (d < 10) {
          if ((after(i) & digits(d)) == after(i)) {
            val need = Integer.bitCount(after(i) ^ digits(d))
            if (j + need <= k) {
              val sum = dp0(j) * 10 + d
              if (sum > dp(j + need)) dp(j + need) = sum
            }
          }
          d += 1
        }
      }
      j += 1
    }
    dp0 = dp
  }

  out.println(dp0(k))

  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 B {

  import InOut._

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

  val digits = Array(
    "1110111",
    "0010010",
    "1011101",
    "1011011",
    "0111010",
    "1101011",
    "1101111",
    "1010010",
    "1111111",
    "1111011"
  ).map(Integer.parseInt(_, 2))

  val n, k = nextInt
  val after = Array.fill(n)(Integer.parseInt(nextLine, 2))

  var dp0 = Array.fill(k + 1)(BigInt(-1))
  dp0(0) = 0
  for (i <- 0 until n) {
    val dp = Array.fill(k + 1)(BigInt(-1))
    var j = 0
    while (j <= k) {
      if (dp0(j) >= -1) {
        var d = 0
        while (d < 10) {
          if ((after(i) & digits(d)) == after(i)) {
            val need = Integer.bitCount(after(i) ^ digits(d))
            if (j + need <= k) {
              val sum = dp0(j) * 10 + d
              if (sum > dp(j + need)) dp(j + need) = sum
            }
          }
          d += 1
        }
      }
      j += 1
    }
    dp0 = dp
    //println(dp0.mkString(" "))
  }

  val res = dp0(k).toString
  out.println("0" * (n - res.length) + res)

  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 B {

  import InOut._

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

  val digits = Array(
    "1110111", //0
    "0010010", //1
    "1011101", //2
    "1011011", //3
    "0111010", //4
    "1101011", //5
    "1101111", //6
    "1010010", //7
    "1111111", //8
    "1111011", //9
  ).map(Integer.parseInt(_, 2))

  val n, k = nextInt
  val after = Array.fill(n)(Integer.parseInt(nextLine, 2))

  var dp0 = Array.fill(k + 1)(-1)
  dp0(0) = 0
  for (i <- 0 until n) {
    val dp = Array.fill(k + 1)(-1)
    var j = 0
    while (j <= k) {
      if (dp0(j) >= -1) {
        var d = 0
        while (d < 10)  {
          if ((after(i) & digits(d)) == after(i)) {
            val need = Integer.bitCount(after(i) ^ digits(d))
            if (j + need <= k) {
              val sum = dp0(j) * 10 + d
              if (sum > dp(j + need)) dp(j + need) = sum
            }
          }
          d += 1
        }
      }
      j += 1
    }
    dp0 = dp
  }

  out.println(dp0(k))

  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
  }

}