package gcj.y2020.round1b

import kotlin.math.abs

private const val SIZE = 1_000_000_000

private fun solve() {
	val grid = listOf(-SIZE / 3, SIZE / 3).cartesianSquare()
	val (xInit, yInit) = grid.first { (x, y) -> hit(x, y) }
	val (xLeft, _) = furthestInside(xInit, yInit, -1, 0)
	val (xRight, _) = furthestInside(xInit, yInit, 1, 0)
	val xCenter = (xLeft + xRight) / 2
	val (_, yUp) = furthestInside(xCenter, yInit, 0, 1)
	val (_, yDown) = furthestInside(xCenter, yInit, 0, -1)
	hit(xCenter, (yUp + yDown) / 2)
}

private fun furthestInside(x: Int, y: Int, dx: Int, dy: Int): Pair<Int, Int> {
	val r = (0..2 * SIZE + 1).binarySearch { !hit(x + dx * it, y + dy * it) } - 1
	return x + dx * r to y + dy * r
}

private fun hit(x: Int, y: Int): Boolean {
	if (maxOf(abs(x), abs(y)) > SIZE) return false
	println("$x $y")
	return "HIT" == readLn().also { if (it == "CENTER") throw Found() }
}

private class Found : Exception()

fun main() = repeat(readLn().split(" ")[0].toInt()) { try { solve() } catch (_: Found) {} }

private fun IntRange.binarySearch(predicate: (Int) -> Boolean): Int {
	var (low, high) = this.first to this.last
	while (low + 1 < high) (low + (high - low) / 2).also { if (predicate(it)) high = it else low = it }
	return high
}

private fun readLn() = readLine()!!
private fun <T> Iterable<T>.cartesianSquare() = flatMap { x -> map { y -> x to y } }

Compiled from "b.kt"
public final class gcj.y2020.round1b.BKt {
  private static final int SIZE;

  private static final void solve();
    Code:
       0: iconst_2
       1: anewarray     #8                  // class java/lang/Integer
       4: astore_1
       5: aload_1
       6: iconst_0
       7: ldc           #9                  // int -333333333
       9: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: aastore
      13: aload_1
      14: iconst_1
      15: ldc           #14                 // int 333333333
      17: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: aastore
      21: aload_1
      22: invokestatic  #20                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      25: checkcast     #22                 // class java/lang/Iterable
      28: invokestatic  #26                 // Method cartesianSquare:(Ljava/lang/Iterable;)Ljava/util/List;
      31: astore_0
      32: aload_0
      33: checkcast     #22                 // class java/lang/Iterable
      36: astore_2
      37: iconst_0
      38: istore_3
      39: aload_2
      40: invokeinterface #30,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        4
      47: aload         4
      49: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          117
      57: aload         4
      59: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        5
      66: aload         5
      68: checkcast     #42                 // class kotlin/Pair
      71: astore        6
      73: iconst_0
      74: istore        7
      76: aload         6
      78: invokevirtual #45                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      81: checkcast     #47                 // class java/lang/Number
      84: invokevirtual #51                 // Method java/lang/Number.intValue:()I
      87: istore        8
      89: aload         6
      91: invokevirtual #54                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      94: checkcast     #47                 // class java/lang/Number
      97: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     100: istore        9
     102: iload         8
     104: iload         9
     106: invokestatic  #58                 // Method hit:(II)Z
     109: ifeq          47
     112: aload         5
     114: goto          127
     117: new           #60                 // class java/util/NoSuchElementException
     120: dup
     121: ldc           #62                 // String Collection contains no element matching the predicate.
     123: invokespecial #66                 // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     126: athrow
     127: checkcast     #42                 // class kotlin/Pair
     130: astore_1
     131: aload_1
     132: invokevirtual #45                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     135: checkcast     #47                 // class java/lang/Number
     138: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     141: istore_2
     142: aload_1
     143: invokevirtual #54                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     146: checkcast     #47                 // class java/lang/Number
     149: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     152: istore_3
     153: iload_2
     154: iload_3
     155: iconst_m1
     156: iconst_0
     157: invokestatic  #70                 // Method furthestInside:(IIII)Lkotlin/Pair;
     160: invokevirtual #45                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     163: checkcast     #47                 // class java/lang/Number
     166: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     169: istore        5
     171: iload_2
     172: iload_3
     173: iconst_1
     174: iconst_0
     175: invokestatic  #70                 // Method furthestInside:(IIII)Lkotlin/Pair;
     178: invokevirtual #45                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     181: checkcast     #47                 // class java/lang/Number
     184: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     187: istore        7
     189: iload         5
     191: iload         7
     193: iadd
     194: iconst_2
     195: idiv
     196: istore        8
     198: iload         8
     200: iload_3
     201: iconst_0
     202: iconst_1
     203: invokestatic  #70                 // Method furthestInside:(IIII)Lkotlin/Pair;
     206: invokevirtual #54                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     209: checkcast     #47                 // class java/lang/Number
     212: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     215: istore        10
     217: iload         8
     219: iload_3
     220: iconst_0
     221: iconst_m1
     222: invokestatic  #70                 // Method furthestInside:(IIII)Lkotlin/Pair;
     225: invokevirtual #54                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     228: checkcast     #47                 // class java/lang/Number
     231: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     234: istore        11
     236: iload         8
     238: iload         10
     240: iload         11
     242: iadd
     243: iconst_2
     244: idiv
     245: invokestatic  #58                 // Method hit:(II)Z
     248: pop
     249: return

  private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> furthestInside(int, int, int, int);
    Code:
       0: new           #95                 // class kotlin/ranges/IntRange
       3: dup
       4: iconst_0
       5: ldc           #96                 // int 2000000001
       7: invokespecial #99                 // Method kotlin/ranges/IntRange."<init>":(II)V
      10: iload_0
      11: iload_2
      12: iload_1
      13: iload_3
      14: invokedynamic #119,  0            // InvokeDynamic #0:invoke:(IIII)Lkotlin/jvm/functions/Function1;
      19: invokestatic  #123                // Method binarySearch:(Lkotlin/ranges/IntRange;Lkotlin/jvm/functions/Function1;)I
      22: iconst_1
      23: isub
      24: istore        4
      26: iload_0
      27: iload_2
      28: iload         4
      30: imul
      31: iadd
      32: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: iload_1
      36: iload_3
      37: iload         4
      39: imul
      40: iadd
      41: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      44: invokestatic  #129                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      47: areturn

  private static final boolean hit(int, int);
    Code:
       0: iload_0
       1: invokestatic  #138                // Method java/lang/Math.abs:(I)I
       4: iload_1
       5: invokestatic  #138                // Method java/lang/Math.abs:(I)I
       8: invokestatic  #142                // Method java/lang/Math.max:(II)I
      11: ldc           #143                // int 1000000000
      13: if_icmple     18
      16: iconst_0
      17: ireturn
      18: new           #145                // class java/lang/StringBuilder
      21: dup
      22: invokespecial #147                // Method java/lang/StringBuilder."<init>":()V
      25: iload_0
      26: invokevirtual #151                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      29: bipush        32
      31: invokevirtual #154                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      34: iload_1
      35: invokevirtual #151                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      38: invokevirtual #158                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      41: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      44: swap
      45: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      48: ldc           #172                // String HIT
      50: invokestatic  #175                // Method readLn:()Ljava/lang/String;
      53: astore_2
      54: aload_2
      55: astore_3
      56: astore        5
      58: iconst_0
      59: istore        4
      61: aload_3
      62: ldc           #177                // String CENTER
      64: invokestatic  #183                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      67: ifeq          78
      70: new           #185                // class gcj/y2020/round1b/Found
      73: dup
      74: invokespecial #186                // Method gcj/y2020/round1b/Found."<init>":()V
      77: athrow
      78: aload         5
      80: aload_2
      81: invokestatic  #183                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      84: ireturn

  public static final void main();
    Code:
       0: invokestatic  #175                // Method readLn:()Ljava/lang/String;
       3: checkcast     #194                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #191                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #196                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #202                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: iconst_0
      26: invokeinterface #206,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #191                // class java/lang/String
      34: invokestatic  #210                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      37: istore_0
      38: iconst_0
      39: istore_1
      40: iload_1
      41: iload_0
      42: if_icmpge     64
      45: iload_1
      46: istore_2
      47: iconst_0
      48: istore_3
      49: nop
      50: invokestatic  #212                // Method solve:()V
      53: goto          58
      56: astore        4
      58: iinc          1, 1
      61: goto          40
      64: return
    Exception table:
       from    to  target type
          49    53    56   Class gcj/y2020/round1b/Found

  private static final int binarySearch(kotlin.ranges.IntRange, kotlin.jvm.functions.Function1<? super java.lang.Integer, java.lang.Boolean>);
    Code:
       0: aload_0
       1: invokevirtual #217                // Method kotlin/ranges/IntRange.getFirst:()I
       4: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       7: aload_0
       8: invokevirtual #220                // Method kotlin/ranges/IntRange.getLast:()I
      11: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: invokestatic  #129                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      17: astore_2
      18: iconst_0
      19: istore_3
      20: aload_2
      21: invokevirtual #45                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      24: checkcast     #47                 // class java/lang/Number
      27: invokevirtual #51                 // Method java/lang/Number.intValue:()I
      30: istore_3
      31: iconst_0
      32: istore        4
      34: aload_2
      35: invokevirtual #54                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      38: checkcast     #47                 // class java/lang/Number
      41: invokevirtual #51                 // Method java/lang/Number.intValue:()I
      44: istore        4
      46: iload_3
      47: iconst_1
      48: iadd
      49: iload         4
      51: if_icmpge     104
      54: iload_3
      55: iload         4
      57: iload_3
      58: isub
      59: iconst_2
      60: idiv
      61: iadd
      62: istore        5
      64: iload         5
      66: istore        6
      68: iconst_0
      69: istore        7
      71: aload_1
      72: iload         6
      74: invokestatic  #13                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: invokeinterface #224,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      82: checkcast     #226                // class java/lang/Boolean
      85: invokevirtual #229                // Method java/lang/Boolean.booleanValue:()Z
      88: ifeq          98
      91: iload         6
      93: istore        4
      95: goto          101
      98: iload         6
     100: istore_3
     101: goto          46
     104: iload         4
     106: ireturn

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #241                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #244                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

  private static final <T> java.util.List<kotlin.Pair<T, T>> cartesianSquare(java.lang.Iterable<? extends T>);
    Code:
       0: aload_0
       1: astore_1
       2: iconst_0
       3: istore_2
       4: aload_1
       5: astore_3
       6: new           #247                // class java/util/ArrayList
       9: dup
      10: invokespecial #248                // Method java/util/ArrayList."<init>":()V
      13: checkcast     #250                // class java/util/Collection
      16: astore        4
      18: iconst_0
      19: istore        5
      21: aload_3
      22: invokeinterface #30,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      27: astore        6
      29: aload         6
      31: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      36: ifeq          168
      39: aload         6
      41: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      46: astore        7
      48: aload         7
      50: astore        8
      52: iconst_0
      53: istore        9
      55: aload_0
      56: astore        10
      58: iconst_0
      59: istore        11
      61: aload         10
      63: astore        12
      65: new           #247                // class java/util/ArrayList
      68: dup
      69: aload         10
      71: bipush        10
      73: invokestatic  #254                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      76: invokespecial #257                // Method java/util/ArrayList."<init>":(I)V
      79: checkcast     #250                // class java/util/Collection
      82: astore        13
      84: iconst_0
      85: istore        14
      87: aload         12
      89: invokeinterface #30,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      94: astore        15
      96: aload         15
      98: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     103: ifeq          145
     106: aload         15
     108: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     113: astore        16
     115: aload         13
     117: aload         16
     119: astore        17
     121: astore        18
     123: iconst_0
     124: istore        19
     126: aload         8
     128: aload         17
     130: invokestatic  #129                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     133: aload         18
     135: swap
     136: invokeinterface #261,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     141: pop
     142: goto          96
     145: aload         13
     147: checkcast     #90                 // class java/util/List
     150: nop
     151: checkcast     #22                 // class java/lang/Iterable
     154: nop
     155: astore        8
     157: aload         4
     159: aload         8
     161: invokestatic  #265                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     164: pop
     165: goto          29
     168: aload         4
     170: checkcast     #90                 // class java/util/List
     173: nop
     174: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #284                // Method main:()V
       3: return

  private static final boolean furthestInside$lambda$1(int, int, int, int, int);
    Code:
       0: iload_0
       1: iload_1
       2: iload         4
       4: imul
       5: iadd
       6: iload_2
       7: iload_3
       8: iload         4
      10: imul
      11: iadd
      12: invokestatic  #58                 // Method hit:(II)Z
      15: ifne          22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ireturn
}


package gcj.y2020.round1b

private fun greedy(init: List<Int>): String {
	var a = init
	val moves = mutableListOf<String>()
	while (a.zipWithNext().any { it.first > it.second }) {
		val pairs = mutableMapOf<Int, Pair<Int, Int>>()
		loop@for (i in 1 until a.size) for (j in i + 1 until a.size) {
			val score = sequenceOf(a[0] != a[j - 1], a[i - 1] == a[i], a[i - 1] != a[j], a[j - 1] == a[j]).count { it }
			pairs[score] = i to j
			if (score == 0) break@loop
		}
		val (i, j) = pairs[pairs.keys.minOrNull()]!!
		a = a.subList(i, j) + a.take(i) + a.drop(j)
		moves.add("$i ${j - i}")
	}
	return "${moves.size}\n${moves.joinToString("\n")}"
}

private fun solve(): String {
	val (r, s) = readInts()
	val a = List(s) { List(r) { it } }.flatten()
	return greedy(a)
}

fun main() = repeat(readInt()) { println("Case #${it + 1}: ${solve()}") }

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "c.kt"
public final class gcj.y2020.round1b.CKt {
  private static final java.lang.String greedy(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: astore_1
       2: new           #9                  // class java/util/ArrayList
       5: dup
       6: invokespecial #13                 // Method java/util/ArrayList."<init>":()V
       9: checkcast     #15                 // class java/util/List
      12: astore_2
      13: aload_1
      14: checkcast     #17                 // class java/lang/Iterable
      17: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
      20: checkcast     #17                 // class java/lang/Iterable
      23: astore_3
      24: iconst_0
      25: istore        4
      27: aload_3
      28: instanceof    #25                 // class java/util/Collection
      31: ifeq          50
      34: aload_3
      35: checkcast     #25                 // class java/util/Collection
      38: invokeinterface #29,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      43: ifeq          50
      46: iconst_0
      47: goto          125
      50: aload_3
      51: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        5
      58: aload         5
      60: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          124
      68: aload         5
      70: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        6
      77: aload         6
      79: checkcast     #44                 // class kotlin/Pair
      82: astore        7
      84: iconst_0
      85: istore        8
      87: aload         7
      89: invokevirtual #47                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      92: checkcast     #49                 // class java/lang/Number
      95: invokevirtual #53                 // Method java/lang/Number.intValue:()I
      98: aload         7
     100: invokevirtual #56                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     103: checkcast     #49                 // class java/lang/Number
     106: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     109: if_icmple     116
     112: iconst_1
     113: goto          117
     116: iconst_0
     117: ifeq          58
     120: iconst_1
     121: goto          125
     124: iconst_0
     125: ifeq          624
     128: new           #58                 // class java/util/LinkedHashMap
     131: dup
     132: invokespecial #59                 // Method java/util/LinkedHashMap."<init>":()V
     135: checkcast     #61                 // class java/util/Map
     138: astore_3
     139: iconst_1
     140: istore        4
     142: aload_1
     143: invokeinterface #64,  1           // InterfaceMethod java/util/List.size:()I
     148: istore        5
     150: iload         4
     152: iload         5
     154: if_icmpge     486
     157: iload         4
     159: iconst_1
     160: iadd
     161: istore        6
     163: aload_1
     164: invokeinterface #64,  1           // InterfaceMethod java/util/List.size:()I
     169: istore        7
     171: iload         6
     173: iload         7
     175: if_icmpge     480
     178: iconst_4
     179: anewarray     #66                 // class java/lang/Boolean
     182: astore        9
     184: aload         9
     186: iconst_0
     187: aload_1
     188: iconst_0
     189: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     194: checkcast     #49                 // class java/lang/Number
     197: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     200: aload_1
     201: iload         6
     203: iconst_1
     204: isub
     205: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     210: checkcast     #49                 // class java/lang/Number
     213: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     216: if_icmpeq     223
     219: iconst_1
     220: goto          224
     223: iconst_0
     224: invokestatic  #74                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     227: aastore
     228: aload         9
     230: iconst_1
     231: aload_1
     232: iload         4
     234: iconst_1
     235: isub
     236: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     241: checkcast     #49                 // class java/lang/Number
     244: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     247: aload_1
     248: iload         4
     250: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     255: checkcast     #49                 // class java/lang/Number
     258: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     261: if_icmpne     268
     264: iconst_1
     265: goto          269
     268: iconst_0
     269: invokestatic  #74                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     272: aastore
     273: aload         9
     275: iconst_2
     276: aload_1
     277: iload         4
     279: iconst_1
     280: isub
     281: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     286: checkcast     #49                 // class java/lang/Number
     289: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     292: aload_1
     293: iload         6
     295: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     300: checkcast     #49                 // class java/lang/Number
     303: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     306: if_icmpeq     313
     309: iconst_1
     310: goto          314
     313: iconst_0
     314: invokestatic  #74                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     317: aastore
     318: aload         9
     320: iconst_3
     321: aload_1
     322: iload         6
     324: iconst_1
     325: isub
     326: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     331: checkcast     #49                 // class java/lang/Number
     334: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     337: aload_1
     338: iload         6
     340: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     345: checkcast     #49                 // class java/lang/Number
     348: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     351: if_icmpne     358
     354: iconst_1
     355: goto          359
     358: iconst_0
     359: invokestatic  #74                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     362: aastore
     363: aload         9
     365: invokestatic  #80                 // Method kotlin/sequences/SequencesKt.sequenceOf:([Ljava/lang/Object;)Lkotlin/sequences/Sequence;
     368: astore        9
     370: iconst_0
     371: istore        10
     373: iconst_0
     374: istore        11
     376: aload         9
     378: invokeinterface #83,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     383: astore        12
     385: aload         12
     387: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     392: ifeq          436
     395: aload         12
     397: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     402: astore        13
     404: aload         13
     406: checkcast     #66                 // class java/lang/Boolean
     409: invokevirtual #86                 // Method java/lang/Boolean.booleanValue:()Z
     412: istore        14
     414: iconst_0
     415: istore        15
     417: iload         14
     419: ifeq          385
     422: iinc          11, 1
     425: iload         11
     427: ifge          385
     430: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     433: goto          385
     436: iload         11
     438: istore        8
     440: iload         8
     442: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     445: astore        10
     447: aload_3
     448: aload         10
     450: iload         4
     452: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     455: iload         6
     457: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     460: invokestatic  #100                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     463: invokeinterface #104,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     468: pop
     469: iload         8
     471: ifeq          486
     474: iinc          6, 1
     477: goto          171
     480: iinc          4, 1
     483: goto          150
     486: aload_3
     487: aload_3
     488: invokeinterface #108,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     493: checkcast     #17                 // class java/lang/Iterable
     496: invokestatic  #112                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     499: invokeinterface #115,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     504: dup
     505: invokestatic  #121                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     508: checkcast     #44                 // class kotlin/Pair
     511: astore        4
     513: aload         4
     515: invokevirtual #124                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     518: checkcast     #49                 // class java/lang/Number
     521: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     524: istore        5
     526: aload         4
     528: invokevirtual #127                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     531: checkcast     #49                 // class java/lang/Number
     534: invokevirtual #53                 // Method java/lang/Number.intValue:()I
     537: istore        6
     539: aload_1
     540: iload         5
     542: iload         6
     544: invokeinterface #131,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     549: checkcast     #25                 // class java/util/Collection
     552: aload_1
     553: checkcast     #17                 // class java/lang/Iterable
     556: iload         5
     558: invokestatic  #135                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     561: checkcast     #17                 // class java/lang/Iterable
     564: invokestatic  #139                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     567: checkcast     #25                 // class java/util/Collection
     570: aload_1
     571: checkcast     #17                 // class java/lang/Iterable
     574: iload         6
     576: invokestatic  #142                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     579: checkcast     #17                 // class java/lang/Iterable
     582: invokestatic  #139                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     585: astore_1
     586: aload_2
     587: new           #144                // class java/lang/StringBuilder
     590: dup
     591: invokespecial #145                // Method java/lang/StringBuilder."<init>":()V
     594: iload         5
     596: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     599: bipush        32
     601: invokevirtual #152                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     604: iload         6
     606: iload         5
     608: isub
     609: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     612: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     615: invokeinterface #160,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     620: pop
     621: goto          13
     624: new           #144                // class java/lang/StringBuilder
     627: dup
     628: invokespecial #145                // Method java/lang/StringBuilder."<init>":()V
     631: aload_2
     632: invokeinterface #64,  1           // InterfaceMethod java/util/List.size:()I
     637: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     640: bipush        10
     642: invokevirtual #152                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     645: aload_2
     646: checkcast     #17                 // class java/lang/Iterable
     649: ldc           #162                // String \n
     651: checkcast     #164                // class java/lang/CharSequence
     654: aconst_null
     655: aconst_null
     656: iconst_0
     657: aconst_null
     658: aconst_null
     659: bipush        62
     661: aconst_null
     662: invokestatic  #168                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     665: invokevirtual #171                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     668: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     671: areturn

  private static final java.lang.String solve();
    Code:
       0: invokestatic  #202                // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #49                 // class java/lang/Number
      14: invokevirtual #53                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #49                 // class java/lang/Number
      28: invokevirtual #53                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: new           #9                  // class java/util/ArrayList
      35: dup
      36: iload_2
      37: invokespecial #205                // Method java/util/ArrayList."<init>":(I)V
      40: astore        4
      42: iconst_0
      43: istore        5
      45: iload         5
      47: iload_2
      48: if_icmpge     137
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        15
      63: iconst_0
      64: istore        8
      66: new           #9                  // class java/util/ArrayList
      69: dup
      70: iload_1
      71: invokespecial #205                // Method java/util/ArrayList."<init>":(I)V
      74: astore        9
      76: iconst_0
      77: istore        10
      79: iload         10
      81: iload_1
      82: if_icmpge     118
      85: iload         10
      87: istore        11
      89: aload         9
      91: iload         11
      93: istore        12
      95: astore        13
      97: iconst_0
      98: istore        14
     100: iload         12
     102: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     105: aload         13
     107: swap
     108: invokevirtual #206                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     111: pop
     112: iinc          10, 1
     115: goto          79
     118: aload         9
     120: checkcast     #15                 // class java/util/List
     123: nop
     124: aload         15
     126: swap
     127: invokevirtual #206                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     130: pop
     131: iinc          5, 1
     134: goto          45
     137: aload         4
     139: checkcast     #15                 // class java/util/List
     142: checkcast     #17                 // class java/lang/Iterable
     145: invokestatic  #209                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     148: astore_3
     149: aload_3
     150: invokestatic  #211                // Method greedy:(Ljava/util/List;)Ljava/lang/String;
     153: areturn

  public static final void main();
    Code:
       0: invokestatic  #219                // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     61
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: new           #144                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #145                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #221                // String Case #
      24: invokevirtual #171                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #223                // String :
      35: invokevirtual #171                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #225                // Method solve:()Ljava/lang/String;
      41: invokevirtual #171                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #231                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #236                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #243                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #121                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

  private static final int readInt();
    Code:
       0: invokestatic  #245                // Method readLn:()Ljava/lang/String;
       3: invokestatic  #249                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #245                // Method readLn:()Ljava/lang/String;
       3: checkcast     #164                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #253                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #255                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #261                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: areturn

  private static final java.util.List<java.lang.Integer> readInts();
    Code:
       0: invokestatic  #264                // Method readStrings:()Ljava/util/List;
       3: checkcast     #17                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #9                  // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #268                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #205                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #25                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #253                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #249                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #94                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #269,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #15                 // class java/util/List
      96: nop
      97: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #281                // Method main:()V
       3: return
}


package gcj.y2020.round1b

private fun solve(): String {
	var (x, y) = readInts()
	val steps = (x.abs() + y.abs()).countSignificantBits()
	return (steps - 1 downTo 0).map { i ->
		val dir = DX.indices.maxByOrNull { x * DX[it] + y * DY[it] }!!
		x -= DX[dir] shl i; y -= DY[dir] shl i
		DIR_ROSE[dir]
	}.joinToString("").reversed().takeIf { x == 0 && y == 0 } ?: "IMPOSSIBLE"
}

private val DX = intArrayOf(1, 0, -1, 0)
private val DY = intArrayOf(0, 1, 0, -1)
private const val DIR_ROSE = "ENWS"

fun main() = repeat(readInt()) { println("Case #${it + 1}: ${solve()}") }

private fun Int.countSignificantBits() = Int.SIZE_BITS - Integer.numberOfLeadingZeros(this)
private fun Int.abs() = kotlin.math.abs(this)
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "a.kt"
public final class gcj.y2020.round1b.AKt {
  private static final int[] DX;

  private static final int[] DY;

  private static final java.lang.String DIR_ROSE;

  private static final java.lang.String solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: iconst_0
       5: istore_1
       6: aload_0
       7: iconst_0
       8: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #18                 // class java/lang/Number
      16: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      19: istore_1
      20: iconst_0
      21: istore_2
      22: aload_0
      23: iconst_1
      24: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #18                 // class java/lang/Number
      32: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      35: istore_2
      36: iload_1
      37: invokestatic  #26                 // Method abs:(I)I
      40: iload_2
      41: invokestatic  #26                 // Method abs:(I)I
      44: iadd
      45: invokestatic  #29                 // Method countSignificantBits:(I)I
      48: istore_3
      49: iload_3
      50: iconst_1
      51: isub
      52: iconst_0
      53: invokestatic  #35                 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      56: checkcast     #37                 // class java/lang/Iterable
      59: astore        4
      61: iconst_0
      62: istore        5
      64: aload         4
      66: astore        6
      68: new           #39                 // class java/util/ArrayList
      71: dup
      72: aload         4
      74: bipush        10
      76: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      79: invokespecial #49                 // Method java/util/ArrayList."<init>":(I)V
      82: checkcast     #51                 // class java/util/Collection
      85: astore        7
      87: iconst_0
      88: istore        8
      90: aload         6
      92: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      97: astore        9
      99: aload         9
     101: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     106: ifeq          349
     109: aload         9
     111: checkcast     #63                 // class kotlin/collections/IntIterator
     114: invokevirtual #66                 // Method kotlin/collections/IntIterator.nextInt:()I
     117: istore        10
     119: aload         7
     121: iload         10
     123: istore        11
     125: astore        22
     127: iconst_0
     128: istore        12
     130: getstatic     #70                 // Field DX:[I
     133: invokestatic  #76                 // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
     136: checkcast     #37                 // class java/lang/Iterable
     139: astore        13
     141: iconst_0
     142: istore        14
     144: aload         13
     146: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        15
     153: aload         15
     155: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifne          167
     163: aconst_null
     164: goto          291
     167: aload         15
     169: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     174: astore        16
     176: aload         15
     178: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     183: ifne          191
     186: aload         16
     188: goto          291
     191: aload         16
     193: checkcast     #18                 // class java/lang/Number
     196: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     199: istore        17
     201: iconst_0
     202: istore        18
     204: iload_1
     205: getstatic     #70                 // Field DX:[I
     208: iload         17
     210: iaload
     211: imul
     212: iload_2
     213: getstatic     #83                 // Field DY:[I
     216: iload         17
     218: iaload
     219: imul
     220: iadd
     221: istore        17
     223: aload         15
     225: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     230: astore        18
     232: aload         18
     234: checkcast     #18                 // class java/lang/Number
     237: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     240: istore        19
     242: iconst_0
     243: istore        20
     245: iload_1
     246: getstatic     #70                 // Field DX:[I
     249: iload         19
     251: iaload
     252: imul
     253: iload_2
     254: getstatic     #83                 // Field DY:[I
     257: iload         19
     259: iaload
     260: imul
     261: iadd
     262: istore        19
     264: iload         17
     266: iload         19
     268: if_icmpge     279
     271: aload         18
     273: astore        16
     275: iload         19
     277: istore        17
     279: aload         15
     281: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     286: ifne          223
     289: aload         16
     291: dup
     292: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     295: checkcast     #18                 // class java/lang/Number
     298: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     301: istore        21
     303: iload_1
     304: getstatic     #70                 // Field DX:[I
     307: iload         21
     309: iaload
     310: iload         11
     312: ishl
     313: isub
     314: istore_1
     315: iload_2
     316: getstatic     #83                 // Field DY:[I
     319: iload         21
     321: iaload
     322: iload         11
     324: ishl
     325: isub
     326: istore_2
     327: ldc           #91                 // String ENWS
     329: iload         21
     331: invokevirtual #97                 // Method java/lang/String.charAt:(I)C
     334: invokestatic  #103                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     337: aload         22
     339: swap
     340: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     345: pop
     346: goto          99
     349: aload         7
     351: checkcast     #12                 // class java/util/List
     354: nop
     355: checkcast     #37                 // class java/lang/Iterable
     358: ldc           #109                // String
     360: checkcast     #111                // class java/lang/CharSequence
     363: aconst_null
     364: aconst_null
     365: iconst_0
     366: aconst_null
     367: aconst_null
     368: bipush        62
     370: aconst_null
     371: invokestatic  #115                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     374: checkcast     #111                // class java/lang/CharSequence
     377: invokestatic  #121                // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     380: invokevirtual #124                // Method java/lang/Object.toString:()Ljava/lang/String;
     383: astore        4
     385: aload         4
     387: astore        5
     389: iconst_0
     390: istore        6
     392: iload_1
     393: ifne          404
     396: iload_2
     397: ifne          404
     400: iconst_1
     401: goto          405
     404: iconst_0
     405: ifeq          413
     408: aload         4
     410: goto          414
     413: aconst_null
     414: dup
     415: ifnonnull     421
     418: pop
     419: ldc           #126                // String IMPOSSIBLE
     421: areturn

  public static final void main();
    Code:
       0: invokestatic  #159                // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     61
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: new           #161                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #163                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #165                // String Case #
      24: invokevirtual #169                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #172                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #174                // String :
      35: invokevirtual #169                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #176                // Method solve:()Ljava/lang/String;
      41: invokevirtual #169                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: invokevirtual #177                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #183                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #188                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static final int countSignificantBits(int);
    Code:
       0: bipush        32
       2: iload_0
       3: invokestatic  #194                // Method java/lang/Integer.numberOfLeadingZeros:(I)I
       6: isub
       7: ireturn

  private static final int abs(int);
    Code:
       0: iload_0
       1: invokestatic  #198                // Method java/lang/Math.abs:(I)I
       4: ireturn

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #205                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

  private static final int readInt();
    Code:
       0: invokestatic  #207                // Method readLn:()Ljava/lang/String;
       3: invokestatic  #211                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #207                // Method readLn:()Ljava/lang/String;
       3: checkcast     #111                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #93                 // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #215                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #219                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: areturn

  private static final java.util.List<java.lang.Integer> readInts();
    Code:
       0: invokestatic  #222                // Method readStrings:()Ljava/util/List;
       3: checkcast     #37                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #39                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #49                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #51                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #93                 // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #211                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #225                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #12                 // class java/util/List
      96: nop
      97: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #229                // Method main:()V
       3: return

  static {};
    Code:
       0: iconst_4
       1: newarray       int
       3: astore_0
       4: aload_0
       5: iconst_0
       6: iconst_1
       7: iastore
       8: aload_0
       9: iconst_1
      10: iconst_0
      11: iastore
      12: aload_0
      13: iconst_2
      14: iconst_m1
      15: iastore
      16: aload_0
      17: iconst_3
      18: iconst_0
      19: iastore
      20: aload_0
      21: putstatic     #70                 // Field DX:[I
      24: iconst_4
      25: newarray       int
      27: astore_0
      28: aload_0
      29: iconst_0
      30: iconst_0
      31: iastore
      32: aload_0
      33: iconst_1
      34: iconst_1
      35: iastore
      36: aload_0
      37: iconst_2
      38: iconst_0
      39: iastore
      40: aload_0
      41: iconst_3
      42: iconst_m1
      43: iastore
      44: aload_0
      45: putstatic     #83                 // Field DY:[I
      48: return
}


package gcj.y2020.round1b

private fun search(init: List<Int>): String {
	val queue = mutableListOf(init)
	val dist = mutableMapOf(init to 0)
	val how = mutableMapOf<List<Int>, Way?>()
	var index = 0
	while (true) {
		val a = queue[index++]
		if (a.zipWithNext().all { it.first <= it.second }) return "${dist[a]}\n${how[a]}"
		for (i in 1 until a.size) for (j in i + 1..a.size) {
			val b = a.subList(i, j) + a.take(i) + a.drop(j)
			if (b in dist) continue
			dist[b] = dist[a]!! + 1
			how[b] = Way(i, j, how[a])
			queue.add(b)
		}
	}
}

private data class Way(val i: Int, val j: Int, val prev: Way?) {
	override fun toString(): String = (if (prev == null) "" else prev.toString() + "\n") + "$i ${j - i}"
}

private fun solve(): String {
	val (r, s) = readInts()
	val a = List(s) { List(r) { it } }.flatten()
	return search(a)
}

fun main() = repeat(readInt()) { println("Case #${it + 1}: ${solve()}") }

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "c_small.kt"
public final class gcj.y2020.round1b.C_smallKt {
  private static final java.lang.String search(java.util.List<java.lang.Integer>);
    Code:
       0: iconst_1
       1: anewarray     #9                  // class java/util/List
       4: astore_2
       5: aload_2
       6: iconst_0
       7: aload_0
       8: aastore
       9: aload_2
      10: invokestatic  #15                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      13: astore_1
      14: iconst_1
      15: anewarray     #17                 // class kotlin/Pair
      18: astore_3
      19: aload_3
      20: iconst_0
      21: aload_0
      22: iconst_0
      23: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: invokestatic  #29                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      29: aastore
      30: aload_3
      31: invokestatic  #35                 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      34: astore_2
      35: new           #37                 // class java/util/LinkedHashMap
      38: dup
      39: invokespecial #41                 // Method java/util/LinkedHashMap."<init>":()V
      42: checkcast     #43                 // class java/util/Map
      45: astore_3
      46: iconst_0
      47: istore        4
      49: nop
      50: aload_1
      51: iload         4
      53: iinc          4, 1
      56: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #9                  // class java/util/List
      64: astore        5
      66: aload         5
      68: checkcast     #49                 // class java/lang/Iterable
      71: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
      74: checkcast     #49                 // class java/lang/Iterable
      77: astore        6
      79: iconst_0
      80: istore        7
      82: aload         6
      84: instanceof    #55                 // class java/util/Collection
      87: ifeq          107
      90: aload         6
      92: checkcast     #55                 // class java/util/Collection
      95: invokeinterface #59,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     100: ifeq          107
     103: iconst_1
     104: goto          183
     107: aload         6
     109: invokeinterface #63,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     114: astore        8
     116: aload         8
     118: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     123: ifeq          182
     126: aload         8
     128: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     133: astore        9
     135: aload         9
     137: checkcast     #17                 // class kotlin/Pair
     140: astore        10
     142: iconst_0
     143: istore        11
     145: aload         10
     147: invokevirtual #75                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     150: checkcast     #77                 // class java/lang/Number
     153: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     156: aload         10
     158: invokevirtual #84                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     161: checkcast     #77                 // class java/lang/Number
     164: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     167: if_icmpgt     174
     170: iconst_1
     171: goto          175
     174: iconst_0
     175: ifne          116
     178: iconst_0
     179: goto          183
     182: iconst_1
     183: ifeq          224
     186: new           #86                 // class java/lang/StringBuilder
     189: dup
     190: invokespecial #87                 // Method java/lang/StringBuilder."<init>":()V
     193: aload_2
     194: aload         5
     196: invokeinterface #90,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     201: invokevirtual #94                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     204: bipush        10
     206: invokevirtual #97                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     209: aload_3
     210: aload         5
     212: invokeinterface #90,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     217: invokevirtual #94                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     220: invokevirtual #101                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     223: areturn
     224: iconst_1
     225: istore        6
     227: aload         5
     229: invokeinterface #104,  1          // InterfaceMethod java/util/List.size:()I
     234: istore        7
     236: iload         6
     238: iload         7
     240: if_icmpge     49
     243: iload         6
     245: iconst_1
     246: iadd
     247: istore        8
     249: aload         5
     251: invokeinterface #104,  1          // InterfaceMethod java/util/List.size:()I
     256: istore        9
     258: iload         8
     260: iload         9
     262: if_icmpgt     412
     265: aload         5
     267: iload         6
     269: iload         8
     271: invokeinterface #108,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     276: checkcast     #55                 // class java/util/Collection
     279: aload         5
     281: checkcast     #49                 // class java/lang/Iterable
     284: iload         6
     286: invokestatic  #112                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     289: checkcast     #49                 // class java/lang/Iterable
     292: invokestatic  #116                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     295: checkcast     #55                 // class java/util/Collection
     298: aload         5
     300: checkcast     #49                 // class java/lang/Iterable
     303: iload         8
     305: invokestatic  #119                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     308: checkcast     #49                 // class java/lang/Iterable
     311: invokestatic  #116                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     314: astore        10
     316: aload_2
     317: aload         10
     319: invokeinterface #123,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     324: ifne          399
     327: aload_2
     328: aload         10
     330: aload_2
     331: aload         5
     333: invokeinterface #90,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     338: dup
     339: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     342: checkcast     #77                 // class java/lang/Number
     345: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     348: iconst_1
     349: iadd
     350: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     353: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     358: pop
     359: aload_3
     360: aload         10
     362: new           #135                // class gcj/y2020/round1b/Way
     365: dup
     366: iload         6
     368: iload         8
     370: aload_3
     371: aload         5
     373: invokeinterface #90,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     378: checkcast     #135                // class gcj/y2020/round1b/Way
     381: invokespecial #138                // Method gcj/y2020/round1b/Way."<init>":(IILgcj/y2020/round1b/Way;)V
     384: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     389: pop
     390: aload_1
     391: aload         10
     393: invokeinterface #141,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     398: pop
     399: iload         8
     401: iload         9
     403: if_icmpeq     412
     406: iinc          8, 1
     409: goto          265
     412: iinc          6, 1
     415: goto          236

  private static final java.lang.String solve();
    Code:
       0: invokestatic  #166                // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #77                 // class java/lang/Number
      14: invokevirtual #81                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #77                 // class java/lang/Number
      28: invokevirtual #81                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: new           #168                // class java/util/ArrayList
      35: dup
      36: iload_2
      37: invokespecial #171                // Method java/util/ArrayList."<init>":(I)V
      40: astore        4
      42: iconst_0
      43: istore        5
      45: iload         5
      47: iload_2
      48: if_icmpge     137
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        15
      63: iconst_0
      64: istore        8
      66: new           #168                // class java/util/ArrayList
      69: dup
      70: iload_1
      71: invokespecial #171                // Method java/util/ArrayList."<init>":(I)V
      74: astore        9
      76: iconst_0
      77: istore        10
      79: iload         10
      81: iload_1
      82: if_icmpge     118
      85: iload         10
      87: istore        11
      89: aload         9
      91: iload         11
      93: istore        12
      95: astore        13
      97: iconst_0
      98: istore        14
     100: iload         12
     102: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     105: aload         13
     107: swap
     108: invokevirtual #172                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     111: pop
     112: iinc          10, 1
     115: goto          79
     118: aload         9
     120: checkcast     #9                  // class java/util/List
     123: nop
     124: aload         15
     126: swap
     127: invokevirtual #172                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     130: pop
     131: iinc          5, 1
     134: goto          45
     137: aload         4
     139: checkcast     #9                  // class java/util/List
     142: checkcast     #49                 // class java/lang/Iterable
     145: invokestatic  #175                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     148: astore_3
     149: aload_3
     150: invokestatic  #177                // Method search:(Ljava/util/List;)Ljava/lang/String;
     153: areturn

  public static final void main();
    Code:
       0: invokestatic  #185                // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     61
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: new           #86                 // class java/lang/StringBuilder
      18: dup
      19: invokespecial #87                 // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #187                // String Case #
      24: invokevirtual #190                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #193                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #195                // String :
      35: invokevirtual #190                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #197                // Method solve:()Ljava/lang/String;
      41: invokevirtual #190                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: invokevirtual #101                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #208                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #215                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

  private static final int readInt();
    Code:
       0: invokestatic  #217                // Method readLn:()Ljava/lang/String;
       3: invokestatic  #221                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #217                // Method readLn:()Ljava/lang/String;
       3: checkcast     #225                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #227                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #229                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #235                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: areturn

  private static final java.util.List<java.lang.Integer> readInts();
    Code:
       0: invokestatic  #238                // Method readStrings:()Ljava/util/List;
       3: checkcast     #49                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #168                // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #242                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #171                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #55                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #63,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #227                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #221                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #23                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #243,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #9                  // class java/util/List
      96: nop
      97: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #255                // Method main:()V
       3: return
}