import java.io._
import scala.io.Source

object Olymp{
  def main(args: Array[String]): Unit = {
    val it = Source.fromFile("input.txt").getLines
    val List(n, k) = it.next.split(' ').toList.map(s => s.toInt)
    val intensity: List[Int] = it.next.split(' ').toList.map(s => s.toInt)
    val solution = (intensity zip (0 to n-1 toList)).sort((a, b) => a._1 > b._1).take(k)
    val writer = new PrintWriter(new File("output.txt" ))
    writer.print(solution.minBy(elem => elem._1)._1+"\n")
    solution.foreach(elem => writer.print((elem._2+1)+" "))
    writer.close()
  }
}

object Solution {
  import scala.io.Source
  import java.io.PrintWriter

  def main(args:Array[String]) {
    val it = Source.fromFile("input.txt").getLines
    val List(n, k) = it.next.split(' ').map(_.toInt).toList
    val hours = it.next.split(' ').map(_.toInt).toArray
    val a = hours.sorted.drop(n-k)
    val min = a.head
    val min_count = a.takeWhile(_ == min).size
    var c = 0
    val reading = (1 to n).view.filter { i =>
      val light = hours(i-1)
      if (light > min) {
        true
      } else if (light == min && c < min_count) {
        c += 1
        true
      } else {
        false
      }

    }.mkString(" ")

    val out = new PrintWriter("output.txt")
    out.println(min)
    out.println(reading)
    out.close
  }
}

object Solution extends App {
  val in = scala.io.Source.fromFile("input.txt").getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = in.next().split(" ").map(_.toInt)
  val sor = data.sorted.drop(n - k)
  var sorted = sor.foldLeft(Map.empty[Int, Int]) {
    case(acc, el) => acc + (el -> (acc.getOrElse(el, 0) + 1))
  }
  val res = data.indices.filter{
    j => if (sorted.getOrElse(data(j), 0) != 0) {
      sorted += (data(j) -> (sorted(data(j)) - 1))
      true
    } else {
      false
    }
  }
  import java.io.{File, PrintWriter}

  val writer = new PrintWriter(new File("output.txt"))
  writer.write(sor.head + "\n" + res.map(_ + 1).mkString(" "))
  writer.close()
}

object Solution extends App {
  val in = scala.io.Source.fromFile("input.txt").getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = in.next().split(" ").map(_.toInt)
  val sor = data.sorted.drop(n - k)
  var sorted = sor.foldLeft(Map.empty[Int, Int]) {
    case(acc, el) => acc + (el -> (acc.getOrElse(el, 0) + 1))
  }
  val res = data.indices.filter{
    j => if (sorted.getOrElse(data(j), 0) != 0) {
      sorted += (data(j) -> (sorted(data(j)) - 1))
      true
    } else {
      false
    }
  }
  import java.io.{File, PrintWriter}

  val writer = new PrintWriter(new File("output.txt"))
  writer.write(sor.head)
  writer.write(res.map(_ + 1).mkString(" "))
  writer.close()
}

object Solution extends App {
  val in = scala.io.Source.fromFile("input.txt").getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = in.next().split(" ").map(_.toInt)
  val sor = data.sorted.drop(n - k)
  var sorted = sor.drop(n - k).foldLeft(Map.empty[Int, Int]) {
    case(acc, el) => acc + (el -> (acc.getOrElse(el, 0) + 1))
  }
  val res = data.indices.filter{
    j => if (sorted.getOrElse(data(j), 0) != 0) {
      sorted += (data(j) -> (sorted(data(j)) - 1))
      true
    } else {
      false
    }
  }
  import java.io.{File, PrintWriter}

  val writer = new PrintWriter(new File("output.txt"))
  writer.write(sor.head)
  writer.write(res.map(_ + 1).mkString(" "))
  writer.close()
}

object Solution extends App {
  println("her")
  val in = scala.io.Source.stdin.getLines()
  // val Array(n, k) = in.next().split(" ").map(_.toInt)
  // val data = in.next().split(" ").map(_.toInt)
//  var sorted = data.sorted.drop(n - k).foldLeft(Map.empty[Int, Int]) {
//    case(acc, el) => acc + (el -> (acc.getOrElse(el, 0) + 1))
//  }
//  val res = data.indices.filter{
//    j => if (sorted.getOrElse(data(j), 0) != 0) {
//      sorted += (data(j) -> (sorted(data(j)) - 1))
//      true
//    } else {
//      false
//    }
//  }
//  println(res.map(_ + 1).mkString(" "))
}

object Solution extends App {
  println("her")
}

object Solution extends App {
  val in = scala.io.Source.fromFile("input.txt").getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val data = in.next().split(" ").map(_.toInt)
  var sorted = data.sorted.drop(n - k).foldLeft(Map.empty[Int, Int]) {
    case(acc, el) => acc + (el -> (acc.getOrElse(el, 0) + 1))
  }
  val res = data.indices.filter{
    j => if (sorted.getOrElse(data(j), 0) != 0) {
      sorted += (data(j) -> (sorted(data(j)) - 1))
      true
    } else {
      false
    }
  }
  import java.io.{File, PrintWriter}

  val writer = new PrintWriter(new File("output.txt"))
  writer.write(res.map(_ + 1).mkString(" "))
  writer.close()
}

import java.io._
import scala.io.Source

object Olymp{
  def main(args: Array[String]): Unit = {
    val it = Source.fromFile("input.txt").getLines
    val List(n, k) = it.next.split(' ').toList.map(s => s.toInt)
    val intensity: List[Int] = it.next.split(' ').toList.map(s => s.toInt)
    val solution = (intensity zip (0 to n-1 toList)).sort((a, b) => a._1 > b._1).take(k)
    val writer = new PrintWriter(new File("output.txt" ))
    writer.print(solution.minBy(elem => elem._1)._1+"\n")
    solution.foreach(elem => writer.print((elem._2+1)+" "))
    writer.print("\n")
  }
}

import java.io._
import scala.io.Source

object Olymp{
  def main(args: Array[String]): Unit = {
    val it = Source.fromFile("input.txt").getLines
    val List(n, k) = it.next.split(' ').toList.map(s => s.toInt)
    val intensity: List[Int] = it.next.split(' ').toList.map(s => s.toInt)
    val solution = (intensity zip (0 to n-1 toList)).sort((a, b) => a._1 > b._1).take(k)
    val writer = new PrintWriter(new File("output.txt" ))
    writer.print(solution.minBy(elem => elem._1)._1+"\n")
    solution.foreach(elem => writer.print((elem._2+1)+" "))
  }
}


import java.util.Scanner

object Main extends App {

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

  val sv =
    (0 to n)
      .toArray

    sv
      .foreach(num => {
        if (num > 1) {
          (num to n by num).tail.foreach(a => sv(a) = 0)
        }
      })

  val a1 =
    sv
      .filter(_ > 1)
      .flatMap(a => {
        val p = (math.log(n) / math.log(a)).toInt
        val t = (1 to p).toArray

        t.foreach(x => t(x - 1) = if (x == 1) a else a * t(x - 2))
        t
      })

  println(a1.size)
  if (a1.nonEmpty)
    println(a1.mkString(" "))
}

import scala.io.StdIn._

object Solution {
    def main( args : Array[String]) {
        val n = readInt
        val prime = Array.fill[Boolean](1005)(true)
        var x = 0 ; var y = 0
        var iset = Set.empty[Int]
        for (x <- 2 to n)
        {
            if(prime(x)==true)
            {
                for(y <- 2*x to n by x)prime(y)=false
                y=x
                while (y<=n)
                {
                    iset = iset + y
                    y = y * x
                }
            }
        }
        println(iset.size)
        iset.foreach(r => printf("%d ", r))
        println()
    }
}

import scala.io.StdIn._

object CF576A extends App {
  val n = readInt()

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n + 1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head,
      primes((nums tail) filter (x => x % nums.head != 0)))

  def powers(i: Int, n: Int): List[Int] = {
    def rec(q: Int, l: List[Int]): List[Int] =
      if (q <= n / i) rec(q * i, q * i :: l)
      else l

    rec(1, List.empty)
  }

//  println(powers(2, n))

  val r = if (n == 1) List.empty
  else
    primes(ints(2))
      .takeWhile(_ <= n)
      .map(powers(_, n))
      .reduce(_ ++ _)

  println(r.size)
  r.foreach(i => {
    print(i)
    print(" ")
  })
  println()
}

import scala.io.StdIn._

object CF576A extends App {
  val n = readInt()

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n + 1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head,
      primes((nums tail) filter (x => x % nums.head != 0)))

  def powers(i: Int): List[Int] = {
    def rec(q: Int, l: List[Int]): List[Int] =
      if (q <= n / i) rec(q * i, q * i :: l)
      else l

    rec(1, List.empty)
  }

  val r = primes(ints(2))
    .takeWhile(_ <= n)
    .map(powers)
    .foldLeft(List.empty[Int]) { _ ++ _ }

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

//package round319.c

import java.util.Scanner

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

  val n = sc.nextInt

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n + 1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head, primes((nums tail) filter (x => x % nums.head != 0)))

  val pp = primes(ints(2)) take 1000 toList

  def isPrime(x: Int): Boolean = {
    pp.contains(x)
  }

  def isPowerOfPrime(x: Int): Boolean = {
    pp.find(x % _ == 0) match {
      case None => false
      case Some(p) =>
        var xx = x
        var res = true
        while(xx != 1) {
          if(xx % p == 0) {
            xx /= p
          } else {
            res = false
            xx = 1
          }
        }
        res
    }
  }

  var divisors = Vector.empty[Int]

  for (i <- 2 to n) {
    if (isPrime(i) || isPowerOfPrime(i)) {
      divisors = divisors :+ i
    }
  }
  println(divisors.size)
  divisors.foreach(d => print(d + " "))

}

import scala.io.StdIn._
import scala.collection.Iterator._
import scala.language.postfixOps

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt
    val prime: Array[Boolean] = Array.ofDim(n + 1)
    //for (val i <- 0 to n - 1)
    prime(0) = true
    prime(1) = true
    for {
      i <- 2 to n
      if !prime(i)
      j <- i * 2 to n by i
    } prime(j) = true
    val it =
    {
      for {
        i <- 2 to n
        if !prime(i)
        j <- iterate(i)(_*i) takeWhile (_ <= n)
      } yield j
    }
    println(it length)
    it foreach(printf(" %d", _:Int))
  }
}

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

  val n = in.next().toInt
  val prime = Array.fill[Boolean](n + 1)(true)
  (2 to n).foreach { i =>
    if (prime(i)) {
      (2 * i to n by i).foreach { j => prime(j) = false}
    }
  }

  var answer = List.empty[Int]
  (2 to n).foreach { i =>
    if (prime(i)) {
      var q = 1
      while (q <= n / i) {
        q *= i
        answer ::= q
      }
    }
  }

  println(answer.length)
  println(answer.mkString(" "))

}

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 C319A(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 C319A(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val n = ni()
    val x = allPrimes(n)
    val y = x.flatMap{ f =>
      Stream.iterate(f)(f*) takeWhile(n>=) toList
    }.toSet
    out.println(y.size)
    out.println(y.mkString(" "))
  }

  def allPrimes(n: Int): Array[Int] = {
    val mrk = Array.fill[Boolean](n+1)(false)
    mrk(0) = true; mrk(1) = true
    REP(n+1) { i =>
      if(i > 1) {
        if(!mrk(i)) {
          i * 2 until (n+1) by i foreach(mrk(_) = true)
        }
      }
    }
    mrk.zipWithIndex.filter(p => !p._1).map(_._2)
  }
}

object A576 {

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

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val res = cu.ArrayBuffer.empty[Int]
    val vis = Array.fill(n+1)(false)
    vis(0) = true
    vis(1) = true
    var i = 2
    while(i <= n) {
      if(!vis(i)) {
        for(j <- vis.indices)
          if(i*j <= n)
            vis(i*j) = true
        res.append(i)

        var k = i*i
        while(k <= n) {
          vis(k) = true
          res.append(k)
          k *= i
        }
      }
      i += 1
    }
    println(res.length)
    println(res.mkString(" "))
  }

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

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

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

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

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

}

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

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object C {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    def query(p: Int) = ???

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

  def solve: Int = {
    val n = nextInt
    val set = new mutable.HashSet[Int]()
    for (i <- 2 to n) {
      val smallSet = new Array[Int](1001)
      var x = i
      for (j <- 2 to Math.sqrt(i).toInt + 1) {
        while (x % j == 0) {
          smallSet(j) += 1
          x /= j
        }
      }
      if (x > 1) {
        smallSet(x) += 1
      }
      var sum = 0
      for (j <- 0 until smallSet.length) {
        sum += smallSet(j)
      }
      if (sum == 1 || sum == 0) {
        set += i
      } else {
        var ind = 0
        var flag = true
        while (ind < smallSet.length && flag) {
          if (smallSet(ind) > 1) {
            if (!set.contains(Math.pow(ind, smallSet(ind)).toInt)) {
              set += i
              flag = false
            }
          }
          ind += 1
        }
      }
    }
    out.println(set.size)
    set.foreach(x => out.print(s"$x "))
    return 0
  }
}

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

object C extends App {

  val n = readLine().toInt

  val answer = new ArrayBuffer[Int]()

  if (n == 1) {
    println(0)
  } else if (n == 2) {
    println(1)
    println(2)
  } else {
    val C = Array.ofDim[Int](n + 1)
    for (i <- 2 to n) C(i) = i

    var div = 2
    var isDiv = true
    while (div <= n) {
      isDiv = false
      var first = true
      for {
        j <- 2 to n
      } {
        if (C(j) > 1 && C(j) % div == 0) {
          isDiv = true
          C(j) /= div
          if (first) {
            answer += j
            first = false
          }
        }
      }

      if (!isDiv) {
        div += 1
      }
    }

    println(answer.length)
    println(answer.mkString(" "))

  }
}

import scala.io.StdIn._

object CF576A extends App {
  val n = readInt()

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n + 1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head,
      primes((nums tail) filter (x => x % nums.head != 0)))

  def powers(i: Int, n: Int): List[Int] = {
    def rec(i: Int, n: Int, l: List[Int]): List[Int] =
      if (i > n) l.drop(1)
      else rec(i * i, n, i * i :: l)

    rec(i, n, List(i))
  }

  val r = if (n == 1) List(1)
  else
    primes(ints(2))
      .takeWhile(_ <= n)
      .map(powers(_, n))
      .reduce(_ ++ _)

  println(r.size)
  r.foreach(i => {
    print(i)
    print(" ")
  })
  println()
}

import scala.io.StdIn._

object CF576A extends App {
  val n = readInt()

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n + 1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head,
      primes((nums tail) filter (x => x % nums.head != 0)))

  def powers(i: Int, n: Int): List[Int] = {
    def rec(i: Int, n: Int, l: List[Int]): List[Int] =
      if (i > n) l.drop(1)
      else rec(i * i, n, i * i :: l)

    rec(i, n, List(i))
  }

  val r = if (n == 1) List.empty
  else
    primes(ints(2))
      .takeWhile(_ <= n)
      .map(powers(_, n))
      .reduce(_ ++ _)

  println(r.size)
  r.foreach(i => {
    print(i)
    print(" ")
  })
  println()
}

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 C319A(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 C319A(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val n = ni()
    val x = allPrimes(n)
    val y = x.flatMap{ f =>
      Stream.iterate(f)(f*) takeWhile(n>=) toList
    }.toSet
    out.println(y.size)
    out.println(y.mkString(","))
  }

  def allPrimes(n: Int): Array[Int] = {
    val mrk = Array.fill[Boolean](n+1)(false)
    mrk(0) = true; mrk(1) = true
    REP(n+1) { i =>
      if(i > 1) {
        if(!mrk(i)) {
          i * 2 until (n+1) by i foreach(mrk(_) = true)
        }
      }
    }
    mrk.zipWithIndex.filter(p => !p._1).map(_._2)
  }
}

import scala.io.StdIn._

object Solution {
    def main( args : Array[String]) {
        val n = readInt
        val prime = Array.fill[Boolean](1005)(true)
        var x = 0 ; var y = 0
        var iset = Set.empty[Int]
        for (x <- 2 to n)
        {
            if(prime(x)==true)
            {
                for(y <- 2*x to n by x)prime(y)=false
                y=x
                while (y<=x)
                {
                    iset = iset + y
                    y = y * x
                }
            }
        }
        println(iset.size)
        iset.foreach(r => printf("%d ", r))
        println()
    }
}

//package round319.c

import java.util.Scanner

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

  val n = sc.nextInt

  def ints(n: Int): Stream[Int] =
    Stream.cons(n, ints(n+1))

  def primes(nums: Stream[Int]): Stream[Int] =
    Stream.cons(nums.head, primes ((nums tail) filter (x => x % nums.head != 0)) )

  val pp = primes(ints(2)) take 1000 toList

  def isPowerOf2(x: Int): Boolean = {
    (x & (x - 1)) == 0
  }

  def isPrime(x: Int): Boolean = {
    pp.contains(x)
  }

  var divisors = Vector.empty[Int]

  if(n == 1) {
    println("0")
  } else if (n == 2) {
    println("1")
    println("2")
  } else {
    for(i <- 2 to n) {
      if(isPowerOf2(i) || isPrime(i)) {
        divisors = divisors :+ i
      }
    }
    println(divisors.size)
    divisors.foreach(d => print(d + " "))
  }

}

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

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object C {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    def query(p: Int) = ???

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

  def solve: Int = {
    val n = nextInt
    val set = new mutable.HashSet[Int]()
    for (i <- 2 to n) {
      val smallSet = new Array[Int](1001)
      var x = i
      for (j <- 2 to Math.sqrt(i).toInt + 1) {
        while (x % j == 0) {
          smallSet(j) += 1
          x /= j
        }
      }
      if (x > 1) {
        smallSet(x) += 1
      }
      var sum = 0
      for (j <- 0 until smallSet.length) {
        sum += smallSet(j)
      }
      if (sum == 1 || sum == 0) {
        set += i
      } else {
        var ind = 0
        var flag = true
        while (ind < smallSet.length && flag) {
          if (smallSet(ind) > 1) {
            if (!set.contains(ind * smallSet(ind))) {
              set += i
              flag = false
            }
          }
          ind += 1
        }
      }
    }
    out.println(set.size)
    set.foreach(x => out.print(s"$x "))
    return 0
  }
}

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

object C extends App {

  val n = readLine().toInt

  val answer = new ArrayBuffer[Int]()

  if (n <= 2) {
    println(n - 1)
  } else {
    val C = Array.ofDim[Int](n + 1)
    for (i <- 2 to n) C(i) = i

    var div = 2
    var isDiv = true
    while (div <= n) {
      isDiv = false
      var first = true
      for {
        j <- 2 to n
      } {
        if (C(j) > 1 && C(j) % div == 0) {
          isDiv = true
          C(j) /= div
          if (first) {
            answer += j
            first = false
          }
        }
      }

      if (!isDiv) {
        div += 1
      }
    }
  }

  println(answer.mkString(" "))
}

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

object C extends App {

  val n = readLine().toInt

  if (n <= 2) {
    println(n - 1)
  } else {

    val C = Array.ofDim[ArrayBuffer[Int]](n + 1)
    val P = Array.fill[Boolean](n + 1)(true)

    for {
      i <- 2 to Math.sqrt(n + 1).toInt
      j <- i + i to n by i
    } {
      P(j) = false
    }

    val primes = P.zipWithIndex.filter(_._1).map(_._2).drop(2)

    for {
      i <- 2 to n
    } {
      var divIdx = 0
      var current = i
      C(i) = new scala.collection.mutable.ArrayBuffer[Int]
      while (divIdx < primes.length && primes(divIdx) <= current) {
        if (current % primes(divIdx) == 0) {
          C(i) += primes(divIdx)
          current /= primes(divIdx)
        } else {
          divIdx += 1
        }
      }
    }

    var isDiv = false
    var i = 0

    val answer = new scala.collection.mutable.ArrayBuffer[Int]
    while (i < primes.length) {
      isDiv = false

      for (j <- 2 to n) {
        if (C(j).nonEmpty && C(j).contains(primes(i))) {
          C(j) -= primes(i)
          if (!isDiv && C(j).isEmpty) {
            answer += j
          }
          isDiv = true
        }
      }

      if (!isDiv) i += 1
    }

    println(answer.mkString(" "))
  }
}


object B {
  def r = readLine().split(" ") map(_.toInt)
  def main(args: Array[String]) {
    var Array(n,k) = r
    var a = r;
    var s = new Array[Int](n)
    s(0)=a(0)
    for (i <- 1 until n)
      s(i) = s(i-1) + a(i);
    var (result,j) = (0,0);
    for (i <- 0 until n-result
      if(a(i) <= k)){
        val ss = if (i == 0) 0 else s(i-1);
        while (j < n && s(j) - ss <= k) {
          j+=1;
          result = math.max(result, j-i)
        }
    }
    println(result)
  }
}

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

    var s = 0
    var sum = 0
    var max = 0

    for (i <- 0 until n) {
      val e = a(i)
      if (sum + e <= t) sum += e
      else {
        if (i - s > max) {
          max = i - s
        }
        sum += e
        sum -= a(s)
        s += 1
      }
    }
    if (n - s > max) max = n - s
    println(max)
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, t) = in.next().split(" ").map(_.toInt)
  val data = in.next().split(" ").map(_.toInt)
  val compressed = data.tail.scanLeft(data.head){case(a, b) => a + b}
  if (t >= compressed.last)
    println(n)
  else {
    var left = -1
    var right = -1
    while (right < n - 1 && compressed(right + 1) <= t)
      right += 1
    var max = right + 1
    while (right < n - 1 && left < n - 1) {
      left += 1
      while (right < n - 1 && compressed(right + 1) - compressed(left) <= t)
        right += 1
      max = Math.max(max, right - left)
    }
    println(max)
  }
}

object B279 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n, t) = readLongs(2)
    val in = Array(0L) ++ readLongs(n.toInt)
    for(i <- 1 to n.toInt) {
      in(i) += in(i-1)
    }
    var res = 0
    var j = 1
    var curr = 0L
    for(i <- 1 to n.toInt) {
      while(j <= n && in(j)-in(i-1) <= t) {
        res = math.max(res, j-i+1)
        j += 1
      }
    }
    println(res)
  }

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

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

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

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

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

}

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

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

  def solve(): Int = {
    val N = sc.nextInt
    val T = sc.nextLong
    val dp = Array.fill(N + 1)(0L)

    for (i <- 1 to N) {
      dp(i) = dp(i - 1) + sc.nextLong
    }

    val idx: Int => Int = { x =>
      if (x < 0) - (x + 1)
      else x + 1
    }

    val books: Int => Int = { i =>
      val j = binarySearch(dp, dp(i - 1) + T)
      idx(j) - i
    }

    0 max List.range(1, N + 1).map(books).max
  }

  out.println(solve)
  out.close
}

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

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

  def solve(): Int = {
    val N = sc.nextInt
    val T = sc.nextLong
    val dp = Array.fill(N + 1)(0L)

    for (i <- 1 to N) {
      dp(i) = dp(i - 1) + sc.nextLong
    }

    val idx: Int => Int = { x =>
      if (x < 0) - (x + 1)
      else x
    }

    val books: Int => Int = { i =>
      val j = binarySearch(dp, dp(i - 1) + T)
      idx(j) - i
    }

    0 max List.range(1, N + 1).map(books).max
  }

  out.println(solve)
  out.close
}


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

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

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

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

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

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

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

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

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

object Workspace {
  import Main._
}

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

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

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

  def solve(): Unit = {
    REP(ni()) { _ =>
      val s = ns()
      val twone = mutable.Set[Int]()
      var i = 0
      while(i != -1) {
        i = s.indexOf("twone", i)
        if (i != -1) {
          twone += i + 2
          i += 5
        }
      }

      val ans = ArrayBuffer[Int]()
      i = 0
      while(i != -1) {
        i = s.indexOf("one", i)
        if (i != -1) {
          if (!twone.contains(i)) {
            ans += i + 1
          }
          i += 3
        }
      }
      i = 0
      while(i != -1) {
        i = s.indexOf("two", i)
        if (i != -1) {
          if (!twone.contains(i + 2)) {
            ans += i + 1
          }
          i += 3
        }
      }

      debug(twone.mkString(" "))
      debug(ans.mkString(" "))

      ans ++= twone
      out.println(ans.length)
      out.println(ans.map(_+1).mkString(" "))
    }
  }
}

object Main {
    def main(args: Array[String]) = {
      val t = readInt
      (0 until t).foreach((x) => f1)
    }
    def f1(): Unit = {
        val s = readLine.zipWithIndex
        val l = s.foldLeft(List[(Char, Int, Int)]()) {
            case (l, (c, i)) => l match {
                case Nil => List((c, i + 1, 1))
                case (c2, k, n) :: tl =>  if (c2 == c) (c2, k, n + 1) :: tl else (c, i + 1, 1) :: l
            }
        }.reverse
        val k = f2(List[(Char, Int, Int)](), List[Int](), l)
        println(k.length)
        println(k.mkString(" "))
    }

    def f2(l: List[(Char, Int, Int)], rl: List[Int], cl: List[(Char, Int, Int)]): List[Int] = {
        cl match {
            case ('o', ooff, on) ::  ('n', noff, 1) :: ('e', eoff, en) :: tl => {
                l match {
                    case ('w', woff, 1) :: ('t', toff, tn) :: ltl => {
                        val (tS, tL) = (('w', woff, 1), ('t', toff, tn))
                        val (oS, oL) = (('n', noff, 1), ('e', eoff, en))
                        if (2 <= on) {
                            f2(oL :: ('o', ooff, on) :: tL :: ltl, oS._2 :: tS._2 :: rl, tl)
                        } else {
                            f2(('e', eoff, en) :: ('n', noff, 1) :: ('w', woff, 1) :: ('t', toff, tn) :: ltl, ooff :: rl, tl)
                        }
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case ('o', ooff, on) :: tl => {
                l match {
                    case ('w', woff, 1) :: ('t', toff, tn) :: ltl => {
                        f2(('o', ooff, on) :: ('t', toff, tn) :: ltl, woff :: rl, tl)
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case ('e', eoff, en) :: tl => {
                l match {
                    case ('n', noff, 1) :: ('o', ooff, on) :: ltl => {
                        f2(('e', eoff, en) :: ('o', ooff, on) :: ltl, noff :: rl, tl)
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case head :: tl => f2(head :: l, rl, tl)
            case Nil => rl
        }
    }
  }

import scala.collection.mutable

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

  val t = nextInt
  for (_ <- 1 to t) {
    val s = nextLine.toCharArray
    def ch(i: Int): Char = if (i < 0 || i >= s.length) ' ' else s(i)
    val res = new mutable.ArrayBuilder.ofInt
    var i = 0
    while (i < s.length) {
      if (ch(i - 2) == 't' && ch(i - 1) == 'w' && ch(i) == 'o' && ch(i + 1) == 'n' && ch(i + 2) == 'e') {
        s(i) = ' '
        res += i + 1
      } else if (ch(i - 2) == 't' && ch(i - 1) == 'w' && ch(i) == 'o') {
        res += i
      } else if (ch(i - 2) == 'o' && ch(i - 1) == 'n' && ch(i) == 'e') {
        res += i
      }
      i += 1
    }
    val r = res.result()
    out.println(r.length)
    out.println(r.mkString(" "))
  }

  out.flush()

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

object Main {
    def main(args: Array[String]) = {
      val t = readInt
      (0 until t).foreach((x) => f1)
    }
    def f1(): Unit = {
        val s = readLine.zipWithIndex
        val l = s.foldLeft(List[(Char, Int, Int)]()) {
            case (l, (c, i)) => l match {
                case Nil => List((c, i, 1))
                case (c2, k, n) :: tl =>  if (c2 == c) (c2, k, n + 1) :: tl else (c, i, 1) :: l
            }
        }.reverse
        //println(l)
        val k = f2(List[(Char, Int, Int)](), List[Int](), l)
        println(k.length)
        println(k.mkString(" "))
    }

    def f2(l: List[(Char, Int, Int)], rl: List[Int], cl: List[(Char, Int, Int)]): List[Int] = {
        cl match {
            case ('o', ooff, on) ::  ('n', noff, 1) :: ('e', eoff, en) :: tl => {
                l match {
                    case ('w', woff, 1) :: ('t', toff, tn) :: ltl => {
                        val (tS, tL) = (('w', woff, 1), ('t', toff, tn))
                        val (oS, oL) = (('n', noff, 1), ('e', eoff, en))
                        if (2 <= on) {
                            f2(oL :: ('o', ooff, on) :: tL :: ltl, oS._2 :: tS._2 :: rl, tl)
                        } else {
                            f2(('e', eoff, en) :: ('n', noff, 1) :: ('w', woff, 1) :: ('t', toff, tn) :: ltl, ooff :: rl, tl)
                        }
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case ('o', ooff, on) :: tl => {
                l match {
                    case ('w', woff, 1) :: ('t', toff, tn) :: ltl => {
                        f2(('o', ooff, on) :: ('t', toff, tn) :: ltl, woff :: rl, tl)
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case ('e', eoff, en) :: tl => {
                l match {
                    case ('n', noff, 1) :: ('o', ooff, on) :: ltl => {
                        f2(('e', eoff, en) :: ('o', ooff, on) :: ltl, noff :: rl, tl)
                    }
                    case _ => f2(cl.head :: l, rl, cl.tail)
                }
            }
            case head :: tl => f2(head :: l, rl, tl)
            case Nil => rl
        }
    }
  }


import java.io._

import scala.io.Source

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

  def processStdInOut(): Unit = {
    val src = Source.fromInputStream(System.in)
    processFromSource(src)
  }

  def processFromSource(src: Source): Unit = {
    try {
      val bw = new BufferedWriter(new OutputStreamWriter(System.out));
      try {
        val lines = src.getLines()
        processLines(lines, bw)
      } finally {
        bw.flush()
      }
    } finally {
      src.close();
    }
  }

  // Standard code above, custom code below
  case class Move(index: Int, direction: Char) {
    override def toString() = s"$index $direction"
  }

  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {
    val n = lines.next().toInt
    val a = lines.next().split(' ').map(_.toInt)
    val k = lines.next().toInt
    val b = lines.next().split(' ').map(_.toInt)
    val solution = solve(n, k, a, b)
    solution match {
      case Some(moves) => {
        bw.write("YES")
        moves.foreach { move =>
          bw.newLine()
          bw.write(move.toString)
        }
      }
      case None => bw.write("NO")
    }
    bw.newLine()
  }

  /** The approach is to folder over the weights in the a matrix,
    * until the current group of a values matches the next b value, and track the largest monster in the group.
    * If there are multiple largest monsters, then the first will eat all monsters to its left then all to its right.
    * The exception is if the first of these largest monsters starts the group and has other largest monsters after it.
    * In this case, take the last largest monster in this initial group of largest monsters.
    * It will eat all monsters to its right, then all monsters to its left.
    * But beware... if all monsters in the group are identical, then there is no solution, as none can eat any other.
    *
    * The Accumulator class tracks the state after all previous weights (entries in a) have been evaluated.
    * In particular it tracks the current group (corresponding to the next b value to be matched).
    */
  case class Accumulator(indexInGroup: Int, sizeOfGroup: Int,
                         groupIndex: Int, groupSum: Int,
                         groupMaxValue: Int, indexOfMaxInGroup: Int, maxStartsGroup: Boolean,
                         moves: IndexedSeq[Move]
                         ) {
    def setNewGroupMaxValue(weight: Int) = copy(
      groupMaxValue = weight,
      indexOfMaxInGroup = indexInGroup,
      maxStartsGroup = (indexInGroup == 0)
    )
    def areAllWeightsIdenticalAndIsThereMoreThanOne: Boolean = {
      maxStartsGroup && (indexOfMaxInGroup == indexInGroup) && (sizeOfGroup > 1)
    }
    def canGroupBeCollapsed: Boolean = !areAllWeightsIdenticalAndIsThereMoreThanOne
    def monstersAfterMaxMonsterInGroup: Int = sizeOfGroup - indexOfMaxInGroup - 1
    def monstersBeforeMaxMonsterInGroup: Int = indexOfMaxInGroup
    def globalIndexOfMaxMonster: Int = groupIndex + indexOfMaxInGroup + 1
    def updateWithMovesToCollapseGroup(): Accumulator = {
      // Calculate the moves that collapse the group to a single value (assuming this is possible)...
      if (sizeOfGroup == 1) this  // With a single monster in the group, no eating will occur
      else {
        val newMoves = if (maxStartsGroup) {
          // Eat monsters to the right, then to the left:
          IndexedSeq.fill(monstersAfterMaxMonsterInGroup)(Move(globalIndexOfMaxMonster, 'R')) ++
          IndexedSeq.tabulate(monstersBeforeMaxMonsterInGroup)(i => Move(globalIndexOfMaxMonster - i, 'L' ))
        } else {
          // Eat monsters to the left, then the right:
          IndexedSeq.tabulate(monstersBeforeMaxMonsterInGroup) (i => Move(globalIndexOfMaxMonster - i, 'L' )) ++
          IndexedSeq.fill(monstersAfterMaxMonsterInGroup)(Move(groupIndex + 1, 'R'))
        }
        this.copy(moves = moves ++ newMoves)
      }
    }
    def startNextGroup(): Accumulator = {
      this.copy(indexInGroup = -1, sizeOfGroup = 0,
        groupIndex = groupIndex + 1, groupSum = 0, groupMaxValue = 0,
        indexOfMaxInGroup = -1, false)
    }
  }

  def solve(n: Int, k: Int, a: Array[Int], b: Array[Int]): Option[Seq[Move]] = {
    val initialAccumulator = Accumulator(-1, 0, 0, 0, 0, -1, false, IndexedSeq[Move]())
    val finalAcc = a.foldLeft[Option[Accumulator]](Some(initialAccumulator)) {
      (maybeAcc: Option[Accumulator], weight: Int) => {
        maybeAcc flatMap { acc =>
          if (b.length <= acc.groupIndex) None  // note enough weights in b to match all the weights in a
          else {
            val target = b(acc.groupIndex)

            // First update the fields that don't depend on other logic:
            var newAcc = acc.copy(
              groupSum = acc.groupSum + weight,
              indexInGroup = acc.indexInGroup + 1,
              sizeOfGroup = acc.sizeOfGroup + 1)

            // Track the maximum value in the group (that isn't surrounded by other biggest monsters),
            // as we can eat up the other monsters starting from it:
            if (newAcc.groupMaxValue < weight) newAcc = newAcc.setNewGroupMaxValue(weight)
            else if (newAcc.maxStartsGroup && (newAcc.groupMaxValue == weight)
              && (newAcc.indexOfMaxInGroup == newAcc.indexInGroup - 1)) {
              // If a block of max values (largest monsters) starts the group, then track the last one found,
              // as only the last one in the block can eat up the rest of the group (by eating right first, not left):
              newAcc = newAcc.copy(indexOfMaxInGroup = newAcc.indexInGroup)
            }

            if (newAcc.groupSum < target) Some(newAcc) // The group is incomplete, so keep iterating...
            else if (newAcc.groupSum > target) None // array a and b are incompatible, so no valid solution
            else if (!newAcc.canGroupBeCollapsed) None // target reached, but all monsters identical, so an impasse
            else {
              newAcc = newAcc.updateWithMovesToCollapseGroup()
              newAcc = newAcc.startNextGroup()
              Some(newAcc)
            }
          }
        }
      }
    }
    finalAcc match {
      case Some(acc) if acc.groupIndex == k => Some(acc.moves)  // Check that all b's were matched
      case _ => None
    }
  }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val n = in.next().toInt
  val line = in.next().split(' ').map(_.toInt)
  val k = in.next().toInt
  val after = in.next().split(' ').map(_.toInt)

  def split(start: Int, current: Int, i: Int, sum: Int, answer: List[Array[Int]]): List[Array[Int]] = {
    if (current == n && i == k)
      answer.reverse
    else if (current == n || i == k)
      Nil
    else if (sum + line(current) == after(i))
      split(current + 1, current + 1, i + 1, 0, line.slice(start, current + 1) :: answer)
    else if (sum + line(current) > after(i))
      Nil
    else
      split(start, current + 1, i, sum + line(current), answer)
  }

  val sol = split(0, 0, 0, 0, Nil).map(_.toList)

  if (sol.exists(l => l.length > 1 && l.distinct.size == 1) || sol.isEmpty) {
    println("NO")
  } else {
    println("YES")
    val res = sol.zipWithIndex.filter(_._1.length > 1).flatMap {
      case (l, index) =>
        val maxValue = l.max
        val maxIndex =
          l.indices.find(i => l(i) == maxValue && ((i != 0 && l(i - 1) != maxValue)
            || (i != l.length - 1 && l(i + 1) != maxValue))).get
        if (maxIndex != 0 && l(maxIndex - 1) != maxValue) {
          (maxIndex to 1 by -1).map(i => s"${i + index + 1} L").toList ::: (maxIndex until l.length - 1).map(i => s"${index + 1} R").toList
        } else {
          (maxIndex until l.length - 1).map(i => s"${maxIndex + index + 1} R").toList ::: (maxIndex to 1 by -1).map(i => s"${i + index + 1} L").toList
        }
    }
    println(res.mkString("\n"))
  }

}

import java.io._

import scala.util._

object Main {

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

    val TEST =
      """2
        |1 2
        |2
        |3 1
      """.stripMargin.trim

    //System.setIn(new ByteArrayInputStream(TEST.getBytes))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      assert(a.sum == b.sum)
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => l.size == 1 || !l.forall(_ == l.head)))
      g.zipWithIndex.filter(_._1.size > 1).flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val n = in.next().toInt
  val line = in.next().split(' ').map(_.toInt)
  val k = in.next().toInt
  val after = in.next().split(' ').map(_.toInt)

  def split(start: Int, current: Int, i: Int, sum: Int, answer: List[Array[Int]]): List[Array[Int]] = {
    if (current == n && i == k)
      answer.reverse
    else if (current == n || i == k)
      Nil
    else if (sum + line(current) == after(i))
      split(current + 1, current + 1, i + 1, 0, line.slice(start, current + 1) :: answer)
    else if (sum + line(current) > after(i))
      Nil
    else
      split(start, current + 1, i, sum + line(current), answer)
  }

  val sol = split(0, 0, 0, 0, Nil).map(_.toList)

  if (sol.exists(l => l.length > 1 && l.distinct.size == 1)) {
    println("NO")
  } else {
    println("YES")
    val res = sol.zipWithIndex.filter(_._1.length > 1).flatMap {
      case (l, index) =>
        val maxValue = l.max
        val maxIndex =
          l.indices.find(i => l(i) == maxValue && ((i != 0 && l(i - 1) != maxValue)
            || (i != l.length - 1 && l(i + 1) != maxValue))).get
        if (maxIndex != 0 && l(maxIndex - 1) != maxValue) {
          (maxIndex to 1 by -1).map(i => s"${i + index + 1} L").toList ::: (maxIndex until l.length - 1).map(i => s"${index + 1} R").toList
        } else {
          (maxIndex until l.length - 1).map(i => s"${maxIndex + index + 1} R").toList ::: (maxIndex to 1 by -1).map(i => s"${i + index + 1} L").toList
        }
    }
    println(res.mkString("\n"))
  }

}

import scala.util._

object Main {

  def main(args: Array[String]) = {
    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length)) {
          assert (l.head.sum + i <= b(l.length))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      assert (f.last.sum == b.last)
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => !l.forall(_ == l.head)))
      g.zipWithIndex.flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

import scala.util._

object Main {

  def main(args: Array[String]) = {
    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length)) {
          assert (l.head.sum + i <= b(l.length))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      assert (f.last.sum == b.last)
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => !l.forall(_ == l.head)))
      g.zipWithIndex.flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => e.getMessage //"NO"
    }

    println(sol)
  }
}

import java.io._

import scala.util._

object Main {

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

    val TEST =
      """
5
1 1 1 1 2
3
1 1 4
      """.stripMargin.trim

//    System.setIn(new ByteArrayInputStream(TEST.getBytes))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => l.size == 1 || !l.forall(_ == l.head)))
      g.zipWithIndex.flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

import java.io._

import scala.util._

object Main {

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

    val TEST =
      """3
        |2 2 1
        |1
        |5
      """.stripMargin.trim

    //System.setIn(new ByteArrayInputStream(TEST.getBytes))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => l.size == 1 || !l.forall(_ == l.head)))
      g.zipWithIndex.filter(_._1.size > 1).flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

import java.io._

import scala.util._

object Main {

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

    val TEST =
      """2
        |1 2
        |2
        |3 1
      """.stripMargin.trim

    //System.setIn(new ByteArrayInputStream(TEST.getBytes))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      assert(a.sum == b.sum)
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      println(g)
      assert(g.forall(l => l.size == 1 || !l.forall(_ == l.head)))
      g.zipWithIndex.filter(_._1.size > 1).flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

import java.io.FileInputStream

import scala.util._

object Main {

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

    //    System.setIn(new FileInputStream("test.txt"))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      assert (g.last.sum == b.last)
      assert(g.forall(l => !l.forall(_ == l.head)))
      g.zipWithIndex.flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}

import java.io._

import scala.util._

object Main {

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

    val TEST =
      """3
        |2 2 1
        |1
        |5
      """.stripMargin.trim

    System.setIn(new ByteArrayInputStream(TEST.getBytes))

    val input = scala.io.Source.stdin.getLines()

    val n = input.next().toInt
    val a = input.next().split(' ').toSeq.map(_.toLong)
    val k = input.next().toInt
    val b = input.next().split(' ').toSeq.map(_.toLong)
    val res = Try {
      val f = a.foldLeft(Seq.empty[Seq[Long]]) { (l, i) =>
        if (l.isEmpty || l.head.sum == b(l.length - 1)) {
          assert (i <= b(l.length))
          Seq(i) +: l
        } else if (l.head.sum < b(l.length - 1)) {
          assert (l.head.sum + i <= b(l.length - 1))
          (i +: l.head) +: l.tail
        } else {
          throw new Exception()
        }
      }
      val g = f.map(_.reverse).reverse
      assert(g.forall(l => l.size == 1 || !l.forall(_ == l.head)))
      g.zipWithIndex.filter(_._1.size > 1).flatMap(pair => {
        val k = pair._1
        val base = pair._2 + 1
        val max = k.max
        val notMaxIndex = k.indexWhere(_ != max)
        val nearestMaxIndex = k.zipWithIndex.filter(pair => pair._1 == max).minBy(a => (a._2 - notMaxIndex).abs)._2
        if (nearestMaxIndex > notMaxIndex) {
          (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L')) ++ (0 until (k.length - nearestMaxIndex - 1)).map(_ => (base, 'R'))
        } else {
          (0 until (k.length - nearestMaxIndex - 1)).map(_ => (nearestMaxIndex + base, 'R')) ++ (0 until nearestMaxIndex).reverse.map(a => (a + base + 1, 'L'))
        }
      })
    }
    val sol = res match {
      case Success(a) => "YES" + a.map(b => "\n" + b._1 + " " + b._2).mkString
      case Failure(e) => "NO"
    }

    println(sol)
  }
}


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

    for (_ <- 1 to nextInt) {
      val n = nextInt
      val as = nextLongs(n)
      var res = n
      if (res == 1) {
        res = 0
      }

      for (l <- 0 until n) {
        val al = as(l)
        for (r <- l + 1 until n) {
          val ar = as(r)
          val d = r - l
          var cntBad = 0
          var i = 0
          while (i < n) {
            val expected = al + (i - l) * (ar - al) / d
            if (expected != as(i) || (i - l) * (ar - al) % d != 0) cntBad += 1
//            println(i, expected, l, r, d)
            i += 1
          }
          if (cntBad < res) {
            res = cntBad
          }
        }
      }

      out.println(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
  }
}

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(val l: Int, val r: Int, val p: Boolean)extends Ordered[pair] {
        override def compare(that: pair): Int = {
            return (r-l).compareTo(that.r-that.l)
        }
    }

    def gcd(a: Int, b: Int): Int = b match {
        case 0 => a
        case n => gcd(b, a % b)
    }
    val rem = 1000000007
    val maxn = 200010
    val mapp = mutable.Map[pair, Int]()

    val t = readInt()

    for (tt <- 1 to t) {
        val n = readInt()
        val arr = new Array[Int](n+1)
        val d = new Array[Int](n+1)
        for (i <- 1 to n) {
            arr(i) = readInt()
        }
        var ans = 0
        var a = 0
        var b = 0
        var c = false
        var tmp = 0
        var p = pair(0, 0, false)
        for (i <- 1 to n) {
            val mp = mutable.Map[pair, Int]()
            //println(i)
            for (j <- 1 to n) {
                if (i != j) {
                    c = false
                    a = arr(i) - arr(j)
                    b = i - j
                    if (a < 0) {
                        a *= -1
                        c = !c
                    }
                    if (b < 0) {
                        b *= -1
                        c = !c
                    }
                    tmp = gcd(a, b)
                    if (tmp != 0) {
                        a /= tmp
                        b /= tmp
                    }
                    p = pair(a, b, c)
                    //println(j, a, b, c)
                    if (!mp.contains(p)) {
                        mp(p) = 1
                        d(i) = max(d(i), 1)
                    } else {
                        tmp = mp(p)
                        mp(p) = tmp + 1
                        d(i) = max(d(i), tmp + 1)
                    }
                }
            }
            ans = max(ans, d(i) + 1)
        }
        writer.println(n - ans)

        def check(kk: Long): Boolean = {
            return true
        }
        def bs(st:Long, en:Long): Long = {
            if (en - st <= 1L) {
                if (check(en))
                    return en
                else
                    return st
            }
            val mid = (st + en) / 2L
            if (check(mid))
                return bs(mid, en)
            else
                return bs(st, mid)
        }
    }
    writer.flush()
}


import scala.io.StdIn._

object B_1265 extends App {
  val t = readInt()
  1 to t foreach { _ =>
    val n = readInt()
    val A = readLine().split(" ").map(_.toInt)
    val pos = A.zipWithIndex.toMap

    var posMax = pos(1)
    var posMin = pos(1)
    val result = Array.fill(n)(false)
    result(0) = true

    2 to n foreach { m =>
      posMax = Math.max(posMax, pos(m))
      posMin = Math.min(posMin, pos(m))
      result(posMax - posMin) = posMax - posMin + 1 == m
//      println(s"$m -> ($posMin, $posMax)")
    }

    println(result.map(x => if (x) "1" else "0").mkString)
    //100000000000000000000001

  }
}

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

  override def solve(io: IO) = io.repeat {
    val ps = io.read[Seq[Int]].zipWithIndex.toMap
    val n = ps.size

    var l = n
    var r = -1

    val ans = (1 to n) map {i =>
      l = l min ps(i)
      r = r max ps(i)
      if (r - l + 1 == i) 1 else 0
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

import scala.io.StdIn._

object B_1265 extends App {
  val t = readInt()
  1 to t foreach { _ =>
    val n = readInt()
    val A = readLine().split(" ").map(_.toInt)
    val pos = A.zipWithIndex.toMap

    var posMax = pos(1)
    var posMin = pos(1)
    val result = Array.fill(n)(false)
    result(0) = true

    2 to n foreach { m =>
      posMax = Math.max(posMax, pos(m))
      posMin = Math.min(posMin, pos(m))
      result(posMax - posMin) = true
    }

    println(result.map(x => if (x) "1" else "0").mkString)

  }
}


object L{
    def main (args: Array[String])= {
        val sc = new java.util.Scanner(System.in)
        val n, k = sc.nextInt()
        val s = sc.next()
        var a = new Array[Int](n+5)
        var last = 0
        for (i<-0 to n-1) {
            if (s.charAt(i)=='0') last=i
            a(i)=last
        }
        var lo = -1
        var hi = n
        while (lo+1<hi) {
            var m=(lo+hi)/2
            var cur=0
            for (i<-2 to k) {
                cur=a(Math.min(n-1, cur+m+1))
            }
            if (cur==n-1) hi=m
            else lo=m
        }
        println(hi)
    }
}

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

/**
  * @author Daniyar Itegulov
  */
object L extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val s = sc.next().map(_ == '0')
  val d = Array.ofDim[Int](n)
  var prev = 0
  d(0) = 0
  for (i <- 1 until n) {
    if (s(i)) {
      prev = i
    }
    d(i) = prev
  }
  var l = -1
  var r = n - 1
  while (r - l > 1) {
    val m = (l + r) / 2
    var pos = 0
    var good = false
    Breaks.breakable {
      for (i <- 0 until (k - 1)) {
        pos = d(Math.min(n - 1, pos + m + 1))
        if (pos == n - 1) {
          good = true
          Breaks.break()
        }
      }
    }
    if (good) {
      r = m
    } else {
      l = m
    }
  }
  println(r)
}

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

/**
  * @author Daniyar Itegulov
  */
object L extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val s = sc.next().map(_ == '0')
  var l = 0
  var r = n - 2
  while (r - l > 1) {
    val m = (l + r) / 2
    var pos = 0
    var good = false
    Breaks.breakable {
      for (i <- 0 until (k - 1)) {
        pos = Math.min(n - 1, pos + m + 1)
        while (!s(pos)) {
          pos -= 1
        }
        if (pos == n - 1) {
          good = true
          Breaks.break()
        }
      }
    }
    if (good) {
      r = m
    } else {
      l = m
    }
  }
  println(r)
}

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

/**
  * @author Daniyar Itegulov
  */
object L extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val s = sc.next().map(_ == '0')
  if (n == 2) {
    print(0)
    System.exit(0)
  }
  var l = 0
  var r = n - 1
  while (r - l > 1) {
    val m = (l + r) / 2
    var pos = 0
    var good = false
    Breaks.breakable {
      for (i <- 0 until (k - 1)) {
        pos = Math.min(n - 1, pos + m + 1)
        while (!s(pos)) {
          pos -= 1
        }
        if (pos == n - 1) {
          good = true
          Breaks.break()
        }
      }
    }
    if (good) {
      r = m
    } else {
      l = m
    }
  }
  println(r)
}

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

/**
  * @author Daniyar Itegulov
  */
object L extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val s = sc.next().map(_ == '0')
  var l = 0
  var r = n - 1
  while (r - l > 1) {
    val m = (l + r) / 2
    var pos = 0
    var good = false
    Breaks.breakable {
      for (i <- 0 until (k - 1)) {
        val prevPos = pos
        pos = Math.min(n - 1, pos + m + 1)
        while (!s(pos)) {
          pos -= 1
        }
        if (pos == n - 1) {
          good = true
          Breaks.break()
        }
      }
    }
    if (good) {
      r = m
    } else {
      l = m
    }
  }
  println(r)
}