package marathons.atcoder.ahc3_shortestPathQueries

import kotlin.random.Random

private fun solve(queries: Int = 1000, size: Int = 30, averageEdge: Int = 5000) {
	val noiseLevel = 0.2
	val random = Random(566)
	fun vertexId(y: Int, x: Int) = y * size + x
	data class Edge(val from: Int, val to: Int, val label: Char, val id: Int)

	val vertices = size * size
	val nei = List(vertices) { mutableListOf<Edge>() }
	var edges = 0
	for (y in 0 until size) for (x in 0 until size) {
		val id = vertexId(y, x)
		for (d in 0..1) {
			val (yy, xx) = y + DY[d] to x + DX[d]
			if (yy >= size || xx >= size) continue
			val id2 = vertexId(yy, xx)
			nei[id].add(Edge(id, id2, DIR[d], edges))
			nei[id2].add(Edge(id2, id, DIR[d xor 2], edges))
			edges++
		}
	}
	val noise = DoubleArray(edges)
	val edgeSum = DoubleArray(edges) { 1.0 }
	val edgeNum = IntArray(edges) { 1 }
	val mark = BooleanArray(vertices)
	val dist = DoubleArray(vertices)
	val how = Array<Edge?>(vertices) { null }
	val inf = 1e20

	fun edgeLength(id: Int): Double {
		return edgeSum[id] / edgeNum[id] + noise[id]
	}

	fun shortestPath(from: Int, to: Int): List<Edge> {
		mark.fill(false)
		dist.fill(inf)
		dist[from] = 0.0
		val queue = sortedMapOf(0.0 to from)
		while (true) {
			val vDist = queue.firstKey()!!
			val v = queue.remove(vDist)!!
			if (v == to) break
			mark[v] = true
			for (e in nei[v]) {
				val u = e.to
				val newDist = vDist + edgeLength(e.id)
				if (newDist < dist[u]) {
					queue.remove(dist[u])
					queue[newDist] = u
					dist[u] = newDist
					how[u] = e
				}
			}
		}
		val path = mutableListOf<Edge>()
		var v = to
		while (v != from) {
			path.add(how[v]!!)
			v = how[v]!!.from
		}
		return path.reversed()
	}

	repeat(queries) {
		val (yFrom, xFrom, yTo, xTo) = readInts()
		val (from, to) = vertexId(yFrom, xFrom) to vertexId(yTo, xTo)
		for (i in noise.indices) noise[i] = random.nextDouble() * noiseLevel
		val path = shortestPath(from, to)
		println(path.joinToString("") { "" + it.label })
		val pathLength = readInt().toDouble() / averageEdge / path.size
		for (e in path) {
			edgeNum[e.id]++
			edgeSum[e.id] += pathLength
		}
 	}

}

fun main() = solve()

val DX = intArrayOf(1, 0, -1, 0)
val DY = intArrayOf(0, 1, 0, -1)
const val DIR = "RDLU"
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "shortestPathQueries.kt"
public final class marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge {
  private final int from;

  private final int to;

  private final char label;

  private final int id;

  public marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge(int, int, char, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field from:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field to:I
      14: aload_0
      15: iload_3
      16: putfield      #20                 // Field label:C
      19: aload_0
      20: iload         4
      22: putfield      #23                 // Field id:I
      25: return

  public final int getFrom();
    Code:
       0: aload_0
       1: getfield      #13                 // Field from:I
       4: ireturn

  public final int getTo();
    Code:
       0: aload_0
       1: getfield      #16                 // Field to:I
       4: ireturn

  public final char getLabel();
    Code:
       0: aload_0
       1: getfield      #20                 // Field label:C
       4: ireturn

  public final int getId();
    Code:
       0: aload_0
       1: getfield      #23                 // Field id:I
       4: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field from:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #16                 // Field to:I
       4: ireturn

  public final char component3();
    Code:
       0: aload_0
       1: getfield      #20                 // Field label:C
       4: ireturn

  public final int component4();
    Code:
       0: aload_0
       1: getfield      #23                 // Field id:I
       4: ireturn

  public final marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge copy(int, int, char, int);
    Code:
       0: new           #2                  // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
       3: dup
       4: iload_1
       5: iload_2
       6: iload_3
       7: iload         4
       9: invokespecial #39                 // Method "<init>":(IICI)V
      12: areturn

  public static marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge copy$default(marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge, int, int, char, int, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field from:I
      11: istore_1
      12: iload         5
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field to:I
      23: istore_2
      24: iload         5
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #20                 // Field label:C
      35: istore_3
      36: iload         5
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #23                 // Field id:I
      48: istore        4
      50: aload_0
      51: iload_1
      52: iload_2
      53: iload_3
      54: iload         4
      56: invokevirtual #43                 // Method copy:(IICI)Lmarathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge;
      59: areturn

  public java.lang.String toString();
    Code:
       0: new           #47                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #50                 // String Edge(from=
       9: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field from:I
      16: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #59                 // String , to=
      21: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field to:I
      28: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #61                 // String , label=
      33: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #20                 // Field label:C
      40: invokevirtual #64                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      43: ldc           #66                 // String , id=
      45: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #23                 // Field id:I
      52: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      55: bipush        41
      57: invokevirtual #64                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      60: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field from:I
       4: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field to:I
      16: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #20                 // Field label:C
      29: invokestatic  #79                 // Method java/lang/Character.hashCode:(C)I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #23                 // Field id:I
      42: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
      45: iadd
      46: istore_1
      47: iload_1
      48: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field from:I
      25: aload_2
      26: getfield      #13                 // Field from:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field to:I
      38: aload_2
      39: getfield      #16                 // Field to:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #20                 // Field label:C
      51: aload_2
      52: getfield      #20                 // Field label:C
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: aload_0
      61: getfield      #23                 // Field id:I
      64: aload_2
      65: getfield      #23                 // Field id:I
      68: if_icmpeq     73
      71: iconst_0
      72: ireturn
      73: iconst_1
      74: ireturn
}

Compiled from "shortestPathQueries.kt"
public final class marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt {
  private static final int[] DX;

  private static final int[] DY;

  public static final java.lang.String DIR;

  private static final void solve(int, int, int);
    Code:
       0: ldc2_w        #7                  // double 0.2d
       3: dstore_3
       4: sipush        566
       7: invokestatic  #14                 // Method kotlin/random/RandomKt.Random:(I)Lkotlin/random/Random;
      10: astore        5
      12: iload_1
      13: iload_1
      14: imul
      15: istore        6
      17: new           #16                 // class java/util/ArrayList
      20: dup
      21: iload         6
      23: invokespecial #20                 // Method java/util/ArrayList."<init>":(I)V
      26: astore        8
      28: iconst_0
      29: istore        9
      31: iload         9
      33: iload         6
      35: if_icmpge     77
      38: iload         9
      40: istore        10
      42: aload         8
      44: iload         10
      46: istore        11
      48: astore        37
      50: iconst_0
      51: istore        12
      53: new           #16                 // class java/util/ArrayList
      56: dup
      57: invokespecial #23                 // Method java/util/ArrayList."<init>":()V
      60: checkcast     #25                 // class java/util/List
      63: nop
      64: aload         37
      66: swap
      67: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      70: pop
      71: iinc          9, 1
      74: goto          31
      77: aload         8
      79: checkcast     #25                 // class java/util/List
      82: astore        7
      84: iconst_0
      85: istore        8
      87: iconst_0
      88: istore        9
      90: iload         9
      92: iload_1
      93: if_icmpge     303
      96: iconst_0
      97: istore        10
      99: iload         10
     101: iload_1
     102: if_icmpge     297
     105: iload_1
     106: iload         9
     108: iload         10
     110: invokestatic  #33                 // Method solve$vertexId:(III)I
     113: istore        11
     115: iconst_0
     116: istore        12
     118: iload         12
     120: iconst_2
     121: if_icmpge     291
     124: iload         9
     126: getstatic     #37                 // Field DY:[I
     129: iload         12
     131: iaload
     132: iadd
     133: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     136: iload         10
     138: getstatic     #46                 // Field DX:[I
     141: iload         12
     143: iaload
     144: iadd
     145: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     148: invokestatic  #52                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     151: astore        13
     153: aload         13
     155: invokevirtual #58                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     158: checkcast     #60                 // class java/lang/Number
     161: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     164: istore        14
     166: aload         13
     168: invokevirtual #67                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     171: checkcast     #60                 // class java/lang/Number
     174: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     177: istore        15
     179: iload         14
     181: iload_1
     182: if_icmpge     285
     185: iload         15
     187: iload_1
     188: if_icmplt     194
     191: goto          285
     194: iload_1
     195: iload         14
     197: iload         15
     199: invokestatic  #33                 // Method solve$vertexId:(III)I
     202: istore        16
     204: aload         7
     206: iload         11
     208: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     213: checkcast     #25                 // class java/util/List
     216: new           #73                 // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
     219: dup
     220: iload         11
     222: iload         16
     224: ldc           #75                 // String RDLU
     226: iload         12
     228: invokevirtual #81                 // Method java/lang/String.charAt:(I)C
     231: iload         8
     233: invokespecial #84                 // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge."<init>":(IICI)V
     236: invokeinterface #85,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     241: pop
     242: aload         7
     244: iload         16
     246: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     251: checkcast     #25                 // class java/util/List
     254: new           #73                 // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
     257: dup
     258: iload         16
     260: iload         11
     262: ldc           #75                 // String RDLU
     264: iload         12
     266: iconst_2
     267: ixor
     268: invokevirtual #81                 // Method java/lang/String.charAt:(I)C
     271: iload         8
     273: invokespecial #84                 // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge."<init>":(IICI)V
     276: invokeinterface #85,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     281: pop
     282: iinc          8, 1
     285: iinc          12, 1
     288: goto          118
     291: iinc          10, 1
     294: goto          99
     297: iinc          9, 1
     300: goto          90
     303: iload         8
     305: newarray       double
     307: astore        9
     309: iconst_0
     310: istore        11
     312: iload         8
     314: istore        12
     316: iload         12
     318: newarray       double
     320: astore        13
     322: iload         11
     324: iload         12
     326: if_icmpge     345
     329: iload         11
     331: istore        14
     333: aload         13
     335: iload         14
     337: dconst_1
     338: dastore
     339: iinc          11, 1
     342: goto          322
     345: aload         13
     347: astore        10
     349: iconst_0
     350: istore        12
     352: iload         8
     354: istore        13
     356: iload         13
     358: newarray       int
     360: astore        14
     362: iload         12
     364: iload         13
     366: if_icmpge     385
     369: iload         12
     371: istore        15
     373: aload         14
     375: iload         15
     377: iconst_1
     378: iastore
     379: iinc          12, 1
     382: goto          362
     385: aload         14
     387: astore        11
     389: iload         6
     391: newarray       boolean
     393: astore        12
     395: iload         6
     397: newarray       double
     399: astore        13
     401: iconst_0
     402: istore        15
     404: iload         6
     406: anewarray     #73                 // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
     409: astore        16
     411: iload         15
     413: iload         6
     415: if_icmpge     434
     418: iload         15
     420: istore        17
     422: aload         16
     424: iload         17
     426: aconst_null
     427: aastore
     428: iinc          15, 1
     431: goto          411
     434: aload         16
     436: astore        14
     438: ldc2_w        #86                 // double 1.0E20d
     441: dstore        15
     443: iconst_0
     444: istore        17
     446: iload         17
     448: iload_0
     449: if_icmpge     773
     452: iload         17
     454: istore        18
     456: iconst_0
     457: istore        19
     459: invokestatic  #91                 // Method readInts:()Ljava/util/List;
     462: astore        20
     464: aload         20
     466: iconst_0
     467: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     472: checkcast     #60                 // class java/lang/Number
     475: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     478: istore        21
     480: aload         20
     482: iconst_1
     483: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     488: checkcast     #60                 // class java/lang/Number
     491: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     494: istore        22
     496: aload         20
     498: iconst_2
     499: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     504: checkcast     #60                 // class java/lang/Number
     507: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     510: istore        23
     512: aload         20
     514: iconst_3
     515: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     520: checkcast     #60                 // class java/lang/Number
     523: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     526: istore        24
     528: iload_1
     529: iload         21
     531: iload         22
     533: invokestatic  #33                 // Method solve$vertexId:(III)I
     536: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     539: iload_1
     540: iload         23
     542: iload         24
     544: invokestatic  #33                 // Method solve$vertexId:(III)I
     547: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     550: invokestatic  #52                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     553: astore        25
     555: aload         25
     557: invokevirtual #58                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     560: checkcast     #60                 // class java/lang/Number
     563: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     566: istore        26
     568: aload         25
     570: invokevirtual #67                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     573: checkcast     #60                 // class java/lang/Number
     576: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     579: istore        27
     581: iconst_0
     582: istore        28
     584: aload         9
     586: arraylength
     587: istore        29
     589: iload         28
     591: iload         29
     593: if_icmpge     614
     596: aload         9
     598: iload         28
     600: aload         5
     602: invokevirtual #97                 // Method kotlin/random/Random.nextDouble:()D
     605: dload_3
     606: dmul
     607: dastore
     608: iinc          28, 1
     611: goto          589
     614: aload         12
     616: aload         13
     618: dload         15
     620: aload         7
     622: aload         14
     624: aload         10
     626: aload         11
     628: aload         9
     630: iload         26
     632: iload         27
     634: invokestatic  #101                // Method solve$shortestPath:([Z[DDLjava/util/List;[Lmarathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge;[D[I[DII)Ljava/util/List;
     637: astore        28
     639: aload         28
     641: checkcast     #103                // class java/lang/Iterable
     644: ldc           #105                // String
     646: checkcast     #107                // class java/lang/CharSequence
     649: aconst_null
     650: aconst_null
     651: iconst_0
     652: aconst_null
     653: invokedynamic #126,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     658: bipush        30
     660: aconst_null
     661: invokestatic  #132                // 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;
     664: getstatic     #138                // Field java/lang/System.out:Ljava/io/PrintStream;
     667: swap
     668: invokevirtual #144                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     671: invokestatic  #147                // Method readInt:()I
     674: i2d
     675: iload_2
     676: i2d
     677: ddiv
     678: aload         28
     680: invokeinterface #150,  1          // InterfaceMethod java/util/List.size:()I
     685: i2d
     686: ddiv
     687: dstore        30
     689: aload         28
     691: invokeinterface #154,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     696: astore        32
     698: aload         32
     700: invokeinterface #160,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     705: ifeq          766
     708: aload         32
     710: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     715: checkcast     #73                 // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
     718: astore        33
     720: aload         33
     722: invokevirtual #166                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getId:()I
     725: istore        34
     727: aload         11
     729: iload         34
     731: iaload
     732: istore        35
     734: aload         11
     736: iload         34
     738: iload         35
     740: iconst_1
     741: iadd
     742: iastore
     743: aload         33
     745: invokevirtual #166                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getId:()I
     748: istore        36
     750: aload         10
     752: iload         36
     754: aload         10
     756: iload         36
     758: daload
     759: dload         30
     761: dadd
     762: dastore
     763: goto          698
     766: nop
     767: iinc          17, 1
     770: goto          446
     773: return

  static void solve$default(int, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          10
       6: sipush        1000
       9: istore_0
      10: iload_3
      11: iconst_2
      12: iand
      13: ifeq          19
      16: bipush        30
      18: istore_1
      19: iload_3
      20: iconst_4
      21: iand
      22: ifeq          29
      25: sipush        5000
      28: istore_2
      29: iload_0
      30: iload_1
      31: iload_2
      32: invokestatic  #215                // Method solve:(III)V
      35: return

  public static final void main();
    Code:
       0: iconst_0
       1: iconst_0
       2: iconst_0
       3: bipush        7
       5: aconst_null
       6: invokestatic  #218                // Method solve$default:(IIIILjava/lang/Object;)V
       9: return

  public static final int[] getDX();
    Code:
       0: getstatic     #46                 // Field DX:[I
       3: areturn

  public static final int[] getDY();
    Code:
       0: getstatic     #37                 // Field DY:[I
       3: areturn

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

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #236                // Method readLn:()Ljava/lang/String;
       3: checkcast     #107                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #77                 // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #244                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #250                // 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  #253                // Method readStrings:()Ljava/util/List;
       3: checkcast     #103                // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #16                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #257                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #20                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #259                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #260,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #160,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #77                 // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #240                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #261,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #25                 // class java/util/List
      96: nop
      97: areturn

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

  private static final int solve$vertexId(int, int, int);
    Code:
       0: iload_1
       1: iload_0
       2: imul
       3: iload_2
       4: iadd
       5: ireturn

  private static final double solve$edgeLength(double[], int[], double[], int);
    Code:
       0: aload_0
       1: iload_3
       2: daload
       3: aload_1
       4: iload_3
       5: iaload
       6: i2d
       7: ddiv
       8: aload_2
       9: iload_3
      10: daload
      11: dadd
      12: dreturn

  private static final java.util.List<marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge> solve$shortestPath(boolean[], double[], double, java.util.List<? extends java.util.List<marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge>>, marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge[], double[], int[], double[], int, int);
    Code:
       0: aload_0
       1: iconst_0
       2: iconst_0
       3: iconst_0
       4: bipush        6
       6: aconst_null
       7: invokestatic  #287                // Method kotlin/collections/ArraysKt.fill$default:([ZZIIILjava/lang/Object;)V
      10: aload_1
      11: dload_2
      12: iconst_0
      13: iconst_0
      14: bipush        6
      16: aconst_null
      17: invokestatic  #290                // Method kotlin/collections/ArraysKt.fill$default:([DDIIILjava/lang/Object;)V
      20: aload_1
      21: iload         9
      23: dconst_0
      24: dastore
      25: iconst_1
      26: anewarray     #54                 // class kotlin/Pair
      29: astore        12
      31: aload         12
      33: iconst_0
      34: dconst_0
      35: invokestatic  #295                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      38: iload         9
      40: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: invokestatic  #52                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      46: aastore
      47: aload         12
      49: invokestatic  #301                // Method kotlin/collections/MapsKt.sortedMapOf:([Lkotlin/Pair;)Ljava/util/SortedMap;
      52: astore        11
      54: nop
      55: aload         11
      57: invokeinterface #306,  1          // InterfaceMethod java/util/SortedMap.firstKey:()Ljava/lang/Object;
      62: dup
      63: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      66: checkcast     #60                 // class java/lang/Number
      69: invokevirtual #309                // Method java/lang/Number.doubleValue:()D
      72: dstore        12
      74: aload         11
      76: dload         12
      78: invokestatic  #295                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      81: invokeinterface #312,  2          // InterfaceMethod java/util/SortedMap.remove:(Ljava/lang/Object;)Ljava/lang/Object;
      86: dup
      87: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      90: checkcast     #60                 // class java/lang/Number
      93: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      96: istore        14
      98: iload         14
     100: iload         10
     102: if_icmpeq     247
     105: aload_0
     106: iload         14
     108: iconst_1
     109: bastore
     110: aload         4
     112: iload         14
     114: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     119: checkcast     #25                 // class java/util/List
     122: invokeinterface #154,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     127: astore        15
     129: aload         15
     131: invokeinterface #160,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     136: ifeq          54
     139: aload         15
     141: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     146: checkcast     #73                 // class marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge
     149: astore        16
     151: aload         16
     153: invokevirtual #315                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getTo:()I
     156: istore        17
     158: dload         12
     160: aload         6
     162: aload         7
     164: aload         8
     166: aload         16
     168: invokevirtual #166                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getId:()I
     171: invokestatic  #317                // Method solve$edgeLength:([D[I[DI)D
     174: dadd
     175: dstore        18
     177: dload         18
     179: aload_1
     180: iload         17
     182: daload
     183: dcmpg
     184: ifge          129
     187: aload         11
     189: aload_1
     190: iload         17
     192: daload
     193: invokestatic  #295                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     196: invokeinterface #312,  2          // InterfaceMethod java/util/SortedMap.remove:(Ljava/lang/Object;)Ljava/lang/Object;
     201: pop
     202: dload         18
     204: invokestatic  #295                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     207: astore        20
     209: iload         17
     211: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     214: astore        21
     216: aload         11
     218: checkcast     #319                // class java/util/Map
     221: aload         20
     223: aload         21
     225: invokeinterface #323,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     230: pop
     231: aload_1
     232: iload         17
     234: dload         18
     236: dastore
     237: aload         5
     239: iload         17
     241: aload         16
     243: aastore
     244: goto          129
     247: new           #16                 // class java/util/ArrayList
     250: dup
     251: invokespecial #23                 // Method java/util/ArrayList."<init>":()V
     254: checkcast     #25                 // class java/util/List
     257: astore        12
     259: iload         10
     261: istore        13
     263: iload         13
     265: iload         9
     267: if_icmpeq     304
     270: aload         12
     272: aload         5
     274: iload         13
     276: aaload
     277: dup
     278: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     281: invokeinterface #85,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     286: pop
     287: aload         5
     289: iload         13
     291: aaload
     292: dup
     293: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     296: invokevirtual #326                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getFrom:()I
     299: istore        13
     301: goto          263
     304: aload         12
     306: checkcast     #103                // class java/lang/Iterable
     309: invokestatic  #330                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     312: areturn

  private static final java.lang.CharSequence solve$lambda$2$lambda$1(marathons.atcoder.ahc3_shortestPathQueries.ShortestPathQueriesKt$solve$Edge);
    Code:
       0: aload_0
       1: ldc_w         #337                // String it
       4: invokestatic  #341                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #343                // class java/lang/StringBuilder
      10: dup
      11: invokespecial #344                // Method java/lang/StringBuilder."<init>":()V
      14: ldc           #105                // String
      16: invokevirtual #348                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: aload_0
      20: invokevirtual #352                // Method marathons/atcoder/ahc3_shortestPathQueries/ShortestPathQueriesKt$solve$Edge.getLabel:()C
      23: invokevirtual #355                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      26: invokevirtual #358                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      29: checkcast     #107                // class java/lang/CharSequence
      32: areturn

  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     #46                 // 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     #37                 // Field DY:[I
      48: return
}


package gcj.y2022.round3

private fun solve(letters: String = "ACDEHIJKMORST"): String {
	val n = readInt()
	val exits = List(2) { readInts().map { it - 1 } }
	val dist1 = List(n) { v -> listOf(exits[0][v], exits[1][v]) }
	val dist2 = List(n) { v -> val d1 = dist1[v]; dist1[d1[0]] + dist1[d1[1]]	}
	val dist12 = List(n) { v -> dist1[v] + dist2[v] }
	for (i in 0 until n) {
		if (i in dist2[i]) return "IMPOSSIBLE"
	}
	val ans = IntArray(n) { -1 }
	val forbid = List(n) { mutableSetOf<Int>() }
	for (i in 0 until n) {
		val fi = forbid[i]
		for (j in dist12[i]) fi.add(ans[j])
		ans[i] = letters.indices.first { it !in fi }
		for (j in dist12[i]) forbid[j].add(ans[i])
	}
	return ans.map { letters[it] }.joinToString("")
}

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.y2022.round3.C_smallKt {
  private static final java.lang.String solve(java.lang.String);
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_1
       4: iconst_2
       5: istore_3
       6: new           #12                 // class java/util/ArrayList
       9: dup
      10: iload_3
      11: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
      14: astore        4
      16: iconst_0
      17: istore        5
      19: iload         5
      21: iload_3
      22: if_icmpge     161
      25: iload         5
      27: istore        6
      29: aload         4
      31: iload         6
      33: istore        7
      35: astore        19
      37: iconst_0
      38: istore        8
      40: invokestatic  #20                 // Method readInts:()Ljava/util/List;
      43: checkcast     #22                 // class java/lang/Iterable
      46: astore        9
      48: iconst_0
      49: istore        10
      51: aload         9
      53: astore        11
      55: new           #12                 // class java/util/ArrayList
      58: dup
      59: aload         9
      61: bipush        10
      63: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      66: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
      69: checkcast     #30                 // class java/util/Collection
      72: astore        12
      74: iconst_0
      75: istore        13
      77: aload         11
      79: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      84: astore        14
      86: aload         14
      88: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      93: ifeq          141
      96: aload         14
      98: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     103: astore        15
     105: aload         12
     107: aload         15
     109: checkcast     #46                 // class java/lang/Number
     112: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     115: istore        16
     117: astore        17
     119: iconst_0
     120: istore        18
     122: iload         16
     124: iconst_1
     125: isub
     126: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: aload         17
     131: swap
     132: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          86
     141: aload         12
     143: checkcast     #61                 // class java/util/List
     146: nop
     147: nop
     148: aload         19
     150: swap
     151: invokevirtual #62                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     154: pop
     155: iinc          5, 1
     158: goto          19
     161: aload         4
     163: checkcast     #61                 // class java/util/List
     166: astore_2
     167: new           #12                 // class java/util/ArrayList
     170: dup
     171: iload_1
     172: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     175: astore        4
     177: iconst_0
     178: istore        5
     180: iload         5
     182: iload_1
     183: if_icmpge     267
     186: iload         5
     188: istore        6
     190: aload         4
     192: iload         6
     194: istore        7
     196: astore        19
     198: iconst_0
     199: istore        8
     201: iconst_2
     202: anewarray     #51                 // class java/lang/Integer
     205: astore        9
     207: aload         9
     209: iconst_0
     210: aload_2
     211: iconst_0
     212: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     217: checkcast     #61                 // class java/util/List
     220: iload         7
     222: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     227: aastore
     228: aload         9
     230: iconst_1
     231: aload_2
     232: iconst_1
     233: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     238: checkcast     #61                 // class java/util/List
     241: iload         7
     243: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     248: aastore
     249: aload         9
     251: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     254: aload         19
     256: swap
     257: invokevirtual #62                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     260: pop
     261: iinc          5, 1
     264: goto          180
     267: aload         4
     269: checkcast     #61                 // class java/util/List
     272: astore_3
     273: new           #12                 // class java/util/ArrayList
     276: dup
     277: iload_1
     278: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     281: astore        5
     283: iconst_0
     284: istore        6
     286: iload         6
     288: iload_1
     289: if_icmpge     382
     292: iload         6
     294: istore        7
     296: aload         5
     298: iload         7
     300: istore        8
     302: astore        19
     304: iconst_0
     305: istore        9
     307: aload_3
     308: iload         8
     310: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     315: checkcast     #61                 // class java/util/List
     318: astore        10
     320: aload_3
     321: aload         10
     323: iconst_0
     324: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     329: checkcast     #46                 // class java/lang/Number
     332: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     335: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     340: checkcast     #30                 // class java/util/Collection
     343: aload_3
     344: aload         10
     346: iconst_1
     347: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     352: checkcast     #46                 // class java/lang/Number
     355: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     358: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     363: checkcast     #22                 // class java/lang/Iterable
     366: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     369: aload         19
     371: swap
     372: invokevirtual #62                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     375: pop
     376: iinc          6, 1
     379: goto          286
     382: aload         5
     384: checkcast     #61                 // class java/util/List
     387: astore        4
     389: new           #12                 // class java/util/ArrayList
     392: dup
     393: iload_1
     394: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     397: astore        6
     399: iconst_0
     400: istore        7
     402: iload         7
     404: iload_1
     405: if_icmpge     462
     408: iload         7
     410: istore        8
     412: aload         6
     414: iload         8
     416: istore        9
     418: astore        19
     420: iconst_0
     421: istore        10
     423: aload_3
     424: iload         9
     426: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     431: checkcast     #30                 // class java/util/Collection
     434: aload         4
     436: iload         9
     438: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     443: checkcast     #22                 // class java/lang/Iterable
     446: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     449: aload         19
     451: swap
     452: invokevirtual #62                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     455: pop
     456: iinc          7, 1
     459: goto          402
     462: aload         6
     464: checkcast     #61                 // class java/util/List
     467: astore        5
     469: iconst_0
     470: istore        6
     472: iload         6
     474: iload_1
     475: if_icmpge     512
     478: aload         4
     480: iload         6
     482: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     487: checkcast     #61                 // class java/util/List
     490: iload         6
     492: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     495: invokeinterface #77,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     500: ifeq          506
     503: ldc           #79                 // String IMPOSSIBLE
     505: areturn
     506: iinc          6, 1
     509: goto          472
     512: iconst_0
     513: istore        7
     515: iload_1
     516: newarray       int
     518: astore        8
     520: iload         7
     522: iload_1
     523: if_icmpge     542
     526: iload         7
     528: istore        9
     530: aload         8
     532: iload         9
     534: iconst_m1
     535: iastore
     536: iinc          7, 1
     539: goto          520
     542: aload         8
     544: astore        6
     546: new           #12                 // class java/util/ArrayList
     549: dup
     550: iload_1
     551: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     554: astore        8
     556: iconst_0
     557: istore        9
     559: iload         9
     561: iload_1
     562: if_icmpge     604
     565: iload         9
     567: istore        10
     569: aload         8
     571: iload         10
     573: istore        11
     575: astore        19
     577: iconst_0
     578: istore        12
     580: new           #81                 // class java/util/LinkedHashSet
     583: dup
     584: invokespecial #84                 // Method java/util/LinkedHashSet."<init>":()V
     587: checkcast     #86                 // class java/util/Set
     590: nop
     591: aload         19
     593: swap
     594: invokevirtual #62                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     597: pop
     598: iinc          9, 1
     601: goto          559
     604: aload         8
     606: checkcast     #61                 // class java/util/List
     609: astore        7
     611: iconst_0
     612: istore        8
     614: iload         8
     616: iload_1
     617: if_icmpge     882
     620: aload         7
     622: iload         8
     624: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     629: checkcast     #86                 // class java/util/Set
     632: astore        9
     634: aload         5
     636: iload         8
     638: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     643: checkcast     #61                 // class java/util/List
     646: invokeinterface #87,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     651: astore        10
     653: aload         10
     655: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     660: ifeq          697
     663: aload         10
     665: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     670: checkcast     #46                 // class java/lang/Number
     673: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     676: istore        11
     678: aload         9
     680: aload         6
     682: iload         11
     684: iaload
     685: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     688: invokeinterface #88,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     693: pop
     694: goto          653
     697: aload         6
     699: iload         8
     701: aload_0
     702: checkcast     #90                 // class java/lang/CharSequence
     705: invokestatic  #96                 // Method kotlin/text/StringsKt.getIndices:(Ljava/lang/CharSequence;)Lkotlin/ranges/IntRange;
     708: checkcast     #22                 // class java/lang/Iterable
     711: astore        10
     713: istore        20
     715: astore        19
     717: iconst_0
     718: istore        11
     720: aload         10
     722: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     727: astore        12
     729: aload         12
     731: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     736: ifeq          784
     739: aload         12
     741: checkcast     #98                 // class kotlin/collections/IntIterator
     744: invokevirtual #101                // Method kotlin/collections/IntIterator.nextInt:()I
     747: istore        13
     749: iload         13
     751: istore        14
     753: iconst_0
     754: istore        15
     756: aload         9
     758: iload         14
     760: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     763: invokeinterface #102,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     768: ifne          775
     771: iconst_1
     772: goto          776
     775: iconst_0
     776: ifeq          729
     779: iload         13
     781: goto          794
     784: new           #104                // class java/util/NoSuchElementException
     787: dup
     788: ldc           #106                // String Collection contains no element matching the predicate.
     790: invokespecial #109                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     793: athrow
     794: istore        21
     796: aload         19
     798: iload         20
     800: iload         21
     802: iastore
     803: aload         5
     805: iload         8
     807: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     812: checkcast     #61                 // class java/util/List
     815: invokeinterface #87,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     820: astore        10
     822: aload         10
     824: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     829: ifeq          876
     832: aload         10
     834: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     839: checkcast     #46                 // class java/lang/Number
     842: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     845: istore        11
     847: aload         7
     849: iload         11
     851: invokeinterface #66,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     856: checkcast     #86                 // class java/util/Set
     859: aload         6
     861: iload         8
     863: iaload
     864: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     867: invokeinterface #88,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     872: pop
     873: goto          822
     876: iinc          8, 1
     879: goto          614
     882: aload         6
     884: astore        8
     886: iconst_0
     887: istore        9
     889: aload         8
     891: astore        10
     893: new           #12                 // class java/util/ArrayList
     896: dup
     897: aload         8
     899: arraylength
     900: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     903: checkcast     #30                 // class java/util/Collection
     906: astore        11
     908: iconst_0
     909: istore        12
     911: iconst_0
     912: istore        13
     914: aload         10
     916: arraylength
     917: istore        14
     919: iload         13
     921: iload         14
     923: if_icmpge     968
     926: aload         10
     928: iload         13
     930: iaload
     931: istore        15
     933: aload         11
     935: iload         15
     937: istore        16
     939: astore        19
     941: iconst_0
     942: istore        17
     944: aload_0
     945: iload         16
     947: invokevirtual #115                // Method java/lang/String.charAt:(I)C
     950: invokestatic  #120                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     953: aload         19
     955: swap
     956: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     961: pop
     962: iinc          13, 1
     965: goto          919
     968: aload         11
     970: checkcast     #61                 // class java/util/List
     973: nop
     974: checkcast     #22                 // class java/lang/Iterable
     977: ldc           #122                // String
     979: checkcast     #90                 // class java/lang/CharSequence
     982: aconst_null
     983: aconst_null
     984: iconst_0
     985: aconst_null
     986: aconst_null
     987: bipush        62
     989: aconst_null
     990: invokestatic  #126                // 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;
     993: areturn

  static java.lang.String solve$default(java.lang.String, int, java.lang.Object);
    Code:
       0: iload_1
       1: iconst_1
       2: iand
       3: ifeq          9
       6: ldc           #170                // String ACDEHIJKMORST
       8: astore_0
       9: aload_0
      10: invokestatic  #172                // Method solve:(Ljava/lang/String;)Ljava/lang/String;
      13: areturn

  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     64
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: new           #175                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #176                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #178                // String Case #
      24: invokevirtual #182                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #185                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #187                // String :
      35: invokevirtual #182                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: aconst_null
      39: iconst_1
      40: aconst_null
      41: invokestatic  #189                // Method solve$default:(Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      44: invokevirtual #182                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      47: invokevirtual #193                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      50: getstatic     #199                // Field java/lang/System.out:Ljava/io/PrintStream;
      53: swap
      54: invokevirtual #205                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      57: nop
      58: iinc          1, 1
      61: goto          6
      64: return

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

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #219                // Method readLn:()Ljava/lang/String;
       3: checkcast     #90                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #111                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #227                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #231                // 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  #234                // Method readStrings:()Ljava/util/List;
       3: checkcast     #22                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #12                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #30                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #111                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #223                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #61                 // class java/util/List
      96: nop
      97: areturn

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


package gcj.y2022.round3

private fun solve(): Long {
	val (n, colors) = readInts()
	val constraints = List(colors) { readInts() }
	val hats = readInts().map { it - 1 }
	val byColor = List(colors) { mutableListOf<Int>() }
	val indexInColor = IntArray(colors)
	for (i in hats.indices) {
		byColor[hats[i]].add(i)
	}
	val x = IntArray(colors)
	val y = IntArray(colors)
	val z = IntArray(colors)
	fun fillXYZ(c: Int, start: Int) {
		val (lowIn, highIn) = constraints[c]
		val ofC = byColor[c]
		if (ofC.size == 0) {
			x[c] = 2 * n; y[c] = -1; z[c] = -1
			return
		}
		val low = maxOf(lowIn, 1)
		val high = minOf(highIn, ofC.size)
		if (start > 0) indexInColor[c]++
		val index = indexInColor[c]
		fun get(i: Int) = if (i < ofC.size) ofC[i] else (ofC[i - ofC.size] + n)
		x[c] = get(index) + 1
		if (ofC.size < low) {
			y[c] = -1; z[c] = -1
		} else {
			y[c] = get(index + low - 1) + 1
			z[c] = if (high >= ofC.size) 2 * n else get(index + high) + 1
		}
	}
	val good = IntArray(2 * n)
	fun add(from: Int, to: Int, value: Int) {
		if (from >= to) return
		for (k in from until to) good[k] += value
	}
	fun count(start: Int): Int {
		var perfects = 0
		for (k in 2 until n) if (good[start + k] == colors) perfects++
		return perfects
	}
	for (c in constraints.indices) {
		fillXYZ(c, 0)
		add(0, x[c], 1)
		add(y[c], z[c], 1)
	}
	var ans = count(0).toLong()
	for (i in 0..n - 2) {
		val c = hats[i]
		add(0, x[c], -1)
		add(y[c], z[c], -1)
		fillXYZ(c, i + 1)
		add(0, x[c], 1)
		add(y[c], z[c], 1)
		ans += count(i + 1)
	}
	return ans
}

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 "b_small.kt"
public final class gcj.y2022.round3.B_smallKt {
  private static final long solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: new           #24                 // class java/util/ArrayList
      35: dup
      36: iload_2
      37: invokespecial #28                 // 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     82
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        16
      63: iconst_0
      64: istore        8
      66: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      69: aload         16
      71: swap
      72: invokevirtual #32                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      75: pop
      76: iinc          5, 1
      79: goto          45
      82: aload         4
      84: checkcast     #12                 // class java/util/List
      87: astore_3
      88: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      91: checkcast     #34                 // class java/lang/Iterable
      94: astore        5
      96: iconst_0
      97: istore        6
      99: aload         5
     101: astore        7
     103: new           #24                 // class java/util/ArrayList
     106: dup
     107: aload         5
     109: bipush        10
     111: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     114: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     117: checkcast     #42                 // class java/util/Collection
     120: astore        8
     122: iconst_0
     123: istore        9
     125: aload         7
     127: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        10
     134: aload         10
     136: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          189
     144: aload         10
     146: invokeinterface #56,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        11
     153: aload         8
     155: aload         11
     157: checkcast     #18                 // class java/lang/Number
     160: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     163: istore        12
     165: astore        16
     167: iconst_0
     168: istore        13
     170: iload         12
     172: iconst_1
     173: isub
     174: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     177: aload         16
     179: swap
     180: invokeinterface #63,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     185: pop
     186: goto          134
     189: aload         8
     191: checkcast     #12                 // class java/util/List
     194: nop
     195: astore        4
     197: new           #24                 // class java/util/ArrayList
     200: dup
     201: iload_2
     202: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     205: astore        6
     207: iconst_0
     208: istore        7
     210: iload         7
     212: iload_2
     213: if_icmpge     255
     216: iload         7
     218: istore        8
     220: aload         6
     222: iload         8
     224: istore        9
     226: astore        16
     228: iconst_0
     229: istore        10
     231: new           #24                 // class java/util/ArrayList
     234: dup
     235: invokespecial #66                 // Method java/util/ArrayList."<init>":()V
     238: checkcast     #12                 // class java/util/List
     241: nop
     242: aload         16
     244: swap
     245: invokevirtual #32                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     248: pop
     249: iinc          7, 1
     252: goto          210
     255: aload         6
     257: checkcast     #12                 // class java/util/List
     260: astore        5
     262: iload_2
     263: newarray       int
     265: astore        6
     267: iconst_0
     268: istore        7
     270: aload         4
     272: checkcast     #42                 // class java/util/Collection
     275: invokeinterface #69,  1           // InterfaceMethod java/util/Collection.size:()I
     280: istore        8
     282: iload         7
     284: iload         8
     286: if_icmpge     331
     289: aload         5
     291: aload         4
     293: iload         7
     295: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     300: checkcast     #18                 // class java/lang/Number
     303: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     306: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     311: checkcast     #12                 // class java/util/List
     314: iload         7
     316: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     319: invokeinterface #70,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     324: pop
     325: iinc          7, 1
     328: goto          282
     331: iload_2
     332: newarray       int
     334: astore        7
     336: iload_2
     337: newarray       int
     339: astore        8
     341: iload_2
     342: newarray       int
     344: astore        9
     346: iconst_2
     347: iload_1
     348: imul
     349: newarray       int
     351: astore        10
     353: iconst_0
     354: istore        11
     356: aload_3
     357: checkcast     #42                 // class java/util/Collection
     360: invokeinterface #69,  1           // InterfaceMethod java/util/Collection.size:()I
     365: istore        12
     367: iload         11
     369: iload         12
     371: if_icmpge     426
     374: aload_3
     375: aload         5
     377: aload         7
     379: iload_1
     380: aload         8
     382: aload         9
     384: aload         6
     386: iload         11
     388: iconst_0
     389: invokestatic  #74                 // Method solve$fillXYZ:(Ljava/util/List;Ljava/util/List;[II[I[I[III)V
     392: aload         10
     394: iconst_0
     395: aload         7
     397: iload         11
     399: iaload
     400: iconst_1
     401: invokestatic  #78                 // Method solve$add:([IIII)V
     404: aload         10
     406: aload         8
     408: iload         11
     410: iaload
     411: aload         9
     413: iload         11
     415: iaload
     416: iconst_1
     417: invokestatic  #78                 // Method solve$add:([IIII)V
     420: iinc          11, 1
     423: goto          367
     426: iload_1
     427: aload         10
     429: iload_2
     430: iconst_0
     431: invokestatic  #82                 // Method solve$count:(I[III)I
     434: i2l
     435: lstore        11
     437: iconst_0
     438: istore        13
     440: iload_1
     441: iconst_2
     442: isub
     443: istore        14
     445: iload         13
     447: iload         14
     449: if_icmpgt     576
     452: aload         4
     454: iload         13
     456: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     461: checkcast     #18                 // class java/lang/Number
     464: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     467: istore        15
     469: aload         10
     471: iconst_0
     472: aload         7
     474: iload         15
     476: iaload
     477: iconst_m1
     478: invokestatic  #78                 // Method solve$add:([IIII)V
     481: aload         10
     483: aload         8
     485: iload         15
     487: iaload
     488: aload         9
     490: iload         15
     492: iaload
     493: iconst_m1
     494: invokestatic  #78                 // Method solve$add:([IIII)V
     497: aload_3
     498: aload         5
     500: aload         7
     502: iload_1
     503: aload         8
     505: aload         9
     507: aload         6
     509: iload         15
     511: iload         13
     513: iconst_1
     514: iadd
     515: invokestatic  #74                 // Method solve$fillXYZ:(Ljava/util/List;Ljava/util/List;[II[I[I[III)V
     518: aload         10
     520: iconst_0
     521: aload         7
     523: iload         15
     525: iaload
     526: iconst_1
     527: invokestatic  #78                 // Method solve$add:([IIII)V
     530: aload         10
     532: aload         8
     534: iload         15
     536: iaload
     537: aload         9
     539: iload         15
     541: iaload
     542: iconst_1
     543: invokestatic  #78                 // Method solve$add:([IIII)V
     546: lload         11
     548: iload_1
     549: aload         10
     551: iload_2
     552: iload         13
     554: iconst_1
     555: iadd
     556: invokestatic  #82                 // Method solve$count:(I[III)I
     559: i2l
     560: ladd
     561: lstore        11
     563: iload         13
     565: iload         14
     567: if_icmpeq     576
     570: iinc          13, 1
     573: goto          452
     576: lload         11
     578: lreturn

  public static final void main();
    Code:
       0: invokestatic  #117                // 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           #119                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #122                // String Case #
      24: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #129                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #131                // String :
      35: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #133                // Method solve:()J
      41: invokevirtual #136                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      44: invokevirtual #140                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #146                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #152                // 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  #159                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #164                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #166                // Method readLn:()Ljava/lang/String;
       3: checkcast     #174                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #176                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #178                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #184                // 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  #187                // Method readStrings:()Ljava/util/List;
       3: checkcast     #34                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #24                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #42                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #56,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #176                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #170                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #62                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #63,  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  #192                // Method main:()V
       3: return

  private static final int solve$fillXYZ$get(java.util.List<java.lang.Integer>, int, int);
    Code:
       0: iload_2
       1: aload_0
       2: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
       7: if_icmpge     26
      10: aload_0
      11: iload_2
      12: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: checkcast     #18                 // class java/lang/Number
      20: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      23: goto          48
      26: aload_0
      27: iload_2
      28: aload_0
      29: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
      34: isub
      35: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #18                 // class java/lang/Number
      43: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      46: iload_1
      47: iadd
      48: ireturn

  private static final void solve$fillXYZ(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>, int[], int, int[], int[], int[], int, int);
    Code:
       0: aload_0
       1: iload         7
       3: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       8: checkcast     #12                 // class java/util/List
      11: astore        9
      13: aload         9
      15: iconst_0
      16: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      21: checkcast     #18                 // class java/lang/Number
      24: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      27: istore        10
      29: aload         9
      31: iconst_1
      32: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #18                 // class java/lang/Number
      40: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      43: istore        11
      45: aload_1
      46: iload         7
      48: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      53: checkcast     #12                 // class java/util/List
      56: astore        12
      58: aload         12
      60: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
      65: ifne          88
      68: aload_2
      69: iload         7
      71: iconst_2
      72: iload_3
      73: imul
      74: iastore
      75: aload         4
      77: iload         7
      79: iconst_m1
      80: iastore
      81: aload         5
      83: iload         7
      85: iconst_m1
      86: iastore
      87: return
      88: iload         10
      90: iconst_1
      91: invokestatic  #206                // Method java/lang/Math.max:(II)I
      94: istore        13
      96: iload         11
      98: aload         12
     100: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
     105: invokestatic  #209                // Method java/lang/Math.min:(II)I
     108: istore        14
     110: iload         8
     112: ifle          131
     115: aload         6
     117: iload         7
     119: iaload
     120: istore        15
     122: aload         6
     124: iload         7
     126: iload         15
     128: iconst_1
     129: iadd
     130: iastore
     131: aload         6
     133: iload         7
     135: iaload
     136: istore        15
     138: aload_2
     139: iload         7
     141: aload         12
     143: iload_3
     144: iload         15
     146: invokestatic  #211                // Method solve$fillXYZ$get:(Ljava/util/List;II)I
     149: iconst_1
     150: iadd
     151: iastore
     152: aload         12
     154: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
     159: iload         13
     161: if_icmpge     179
     164: aload         4
     166: iload         7
     168: iconst_m1
     169: iastore
     170: aload         5
     172: iload         7
     174: iconst_m1
     175: iastore
     176: goto          235
     179: aload         4
     181: iload         7
     183: aload         12
     185: iload_3
     186: iload         15
     188: iload         13
     190: iadd
     191: iconst_1
     192: isub
     193: invokestatic  #211                // Method solve$fillXYZ$get:(Ljava/util/List;II)I
     196: iconst_1
     197: iadd
     198: iastore
     199: aload         5
     201: iload         7
     203: iload         14
     205: aload         12
     207: invokeinterface #198,  1          // InterfaceMethod java/util/List.size:()I
     212: if_icmplt     221
     215: iconst_2
     216: iload_3
     217: imul
     218: goto          234
     221: aload         12
     223: iload_3
     224: iload         15
     226: iload         14
     228: iadd
     229: invokestatic  #211                // Method solve$fillXYZ$get:(Ljava/util/List;II)I
     232: iconst_1
     233: iadd
     234: iastore
     235: return

  private static final void solve$add(int[], int, int, int);
    Code:
       0: iload_1
       1: iload_2
       2: if_icmplt     6
       5: return
       6: iload_1
       7: istore        4
       9: iload         4
      11: iload_2
      12: if_icmpge     35
      15: iload         4
      17: istore        5
      19: aload_0
      20: iload         5
      22: aload_0
      23: iload         5
      25: iaload
      26: iload_3
      27: iadd
      28: iastore
      29: iinc          4, 1
      32: goto          9
      35: return

  private static final int solve$count(int, int[], int, int);
    Code:
       0: iconst_0
       1: istore        4
       3: iconst_2
       4: istore        5
       6: iload         5
       8: iload_0
       9: if_icmpge     31
      12: aload_1
      13: iload_3
      14: iload         5
      16: iadd
      17: iaload
      18: iload_2
      19: if_icmpne     25
      22: iinc          4, 1
      25: iinc          5, 1
      28: goto          6
      31: iload         4
      33: ireturn
}


package gcj.y2022.round2

private fun solve(): String {
	val (n, k) = readInts()
	var x = 1
	var w = n - 1
	val ans = mutableListOf<String>()
	var toCut = n * n - 1 - k
	var where = 1
	while (w > 0) {
		val y = x + 4 * w
		repeat(4) { i ->
			val from = x + i * w + 1
			val to = y + i * (w - 2)
			val cut = to - from - 1
			if (cut in 1..toCut && from >= where) {
				ans.add("$from $to")
				toCut -= cut
				where = to
			}
		}
		w -= 2
		x = y
	}
	if (toCut != 0) return "IMPOSSIBLE"
	return "" + ans.size + "\n" + ans.joinToString("\n")
}

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 "a.kt"
public final class gcj.y2022.round2.AKt {
  private static final java.lang.String solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: iconst_0
      33: istore_3
      34: iconst_1
      35: istore_3
      36: iconst_0
      37: istore        4
      39: iload_1
      40: iconst_1
      41: isub
      42: istore        4
      44: new           #24                 // class java/util/ArrayList
      47: dup
      48: invokespecial #28                 // Method java/util/ArrayList."<init>":()V
      51: checkcast     #12                 // class java/util/List
      54: astore        5
      56: iconst_0
      57: istore        6
      59: iload_1
      60: iload_1
      61: imul
      62: iconst_1
      63: isub
      64: iload_2
      65: isub
      66: istore        6
      68: iconst_0
      69: istore        7
      71: iconst_1
      72: istore        7
      74: iload         4
      76: ifle          234
      79: iload_3
      80: iconst_4
      81: iload         4
      83: imul
      84: iadd
      85: istore        8
      87: iconst_4
      88: istore        9
      90: iconst_0
      91: istore        10
      93: iload         10
      95: iload         9
      97: if_icmpge     222
     100: iload         10
     102: istore        11
     104: iconst_0
     105: istore        12
     107: iload_3
     108: iload         11
     110: iload         4
     112: imul
     113: iadd
     114: iconst_1
     115: iadd
     116: istore        13
     118: iload         8
     120: iload         11
     122: iload         4
     124: iconst_2
     125: isub
     126: imul
     127: iadd
     128: istore        14
     130: iload         14
     132: iload         13
     134: isub
     135: iconst_1
     136: isub
     137: istore        15
     139: iconst_1
     140: iload         15
     142: if_icmpgt     160
     145: iload         15
     147: iload         6
     149: if_icmpgt     156
     152: iconst_1
     153: goto          161
     156: iconst_0
     157: goto          161
     160: iconst_0
     161: ifeq          215
     164: iload         13
     166: iload         7
     168: if_icmplt     215
     171: aload         5
     173: new           #30                 // class java/lang/StringBuilder
     176: dup
     177: invokespecial #31                 // Method java/lang/StringBuilder."<init>":()V
     180: iload         13
     182: invokevirtual #35                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     185: bipush        32
     187: invokevirtual #38                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     190: iload         14
     192: invokevirtual #35                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     195: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     198: invokeinterface #45,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     203: pop
     204: iload         6
     206: iload         15
     208: isub
     209: istore        6
     211: iload         14
     213: istore        7
     215: nop
     216: iinc          10, 1
     219: goto          93
     222: iload         4
     224: iconst_2
     225: isub
     226: istore        4
     228: iload         8
     230: istore_3
     231: goto          74
     234: iload         6
     236: ifeq          242
     239: ldc           #47                 // String IMPOSSIBLE
     241: areturn
     242: new           #30                 // class java/lang/StringBuilder
     245: dup
     246: invokespecial #31                 // Method java/lang/StringBuilder."<init>":()V
     249: ldc           #49                 // String
     251: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     254: aload         5
     256: invokeinterface #55,  1           // InterfaceMethod java/util/List.size:()I
     261: invokevirtual #35                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     264: bipush        10
     266: invokevirtual #38                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     269: aload         5
     271: checkcast     #57                 // class java/lang/Iterable
     274: ldc           #59                 // String \n
     276: checkcast     #61                 // class java/lang/CharSequence
     279: aconst_null
     280: aconst_null
     281: iconst_0
     282: aconst_null
     283: aconst_null
     284: bipush        62
     286: aconst_null
     287: invokestatic  #67                 // 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;
     290: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     293: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     296: areturn

  public static final void main();
    Code:
       0: invokestatic  #86                 // 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           #30                 // class java/lang/StringBuilder
      18: dup
      19: invokespecial #31                 // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #88                 // String Case #
      24: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #35                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #90                 // String :
      35: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #92                 // Method solve:()Ljava/lang/String;
      41: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #98                 // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #104                // 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  #112                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #117                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #119                // Method readLn:()Ljava/lang/String;
       3: checkcast     #61                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #129                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #131                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #137                // 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  #140                // Method readStrings:()Ljava/util/List;
       3: checkcast     #57                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #24                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #144                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #147                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #149                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #153,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #159,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #129                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #125                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #167                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #168,  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  #182                // Method main:()V
       3: return
}