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


  val Array(n, k)  = readLine.trim.split(' ').map(_.toInt)
  val digit = calMaxDigit(n)
  val edges = makeGraph(n)
  println(edges.length)
  if (edges.nonEmpty) println(edges.map(s ⇒ s"${s._1} ${s._2}").mkString("\n"))
  for (_ ← 0 until k){
    var result = 0
    var response = "No"
    var count = 0
    while(response != "Yes" && count <= digit) {
      println(1 << (digit - count))
      response = readLine.trim
      if (response == "No") result *= 2
      else result = (result * 2) + 1
      count += 1
    }
    if (response != "Yes") {
      println(result)
      readLine()
    }
  }
  def calMaxDigit(n: Int): Int = {
    if (n != 1) calMaxDigit(n / 2) + 1
    else 0
  }
  def makeGraph(n: Int, digit: Int = 1, result: List[(Int, Int)] = Nil): List[(Int, Int)] = {
    if (digit <= n){
      makeGraph(n, digit << 1, (1 to n).filter(i ⇒ i != digit && (i & digit) != 0).map((digit, _)).toList ++ result)
    }else result
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}
