package facebook.y2019.round1

private fun solve(): Int {
	val (n, hei) = readInts()
	data class Ladder(val id: Int, val x: Int, val yFrom: Int, val yTo: Int)
	val ladders = List(n) {	val (x, yFrom, yTo) = readInts(); Ladder(it, x, yFrom, yTo) }

	val e = Array(n + 2) { IntArray(n + 2) }
	val ys = ladders.flatMap { listOf(it.yFrom, it.yTo) }.toSet().sorted()
	for ((y, yNext) in ys.zipWithNext()) {
		val idsOrdered = ladders.filter { (it.yFrom <= y) && (y < it.yTo) }.sortedBy { it.x }.map { it.id }
		for ((i, j) in idsOrdered.zipWithNext()) {
			e[i][j] += yNext - y
			e[j][i] += yNext - y
		}
	}
	val inf = n * hei
	ladders.forEach {
		if (it.yFrom == 0) { e[n][it.id] = inf }
		if (it.yTo == hei) { e[it.id][n + 1] = inf }
	}
	return edmonsKarp(e, n, n + 1).takeIf { it < inf } ?: -1
}

fun edmonsKarp(c: Array<IntArray>, s: Int, t: Int): Int {
	val n = c.size
	val f = Array(n) { IntArray(n) }
	val queue = IntArray(n)
	val prev = IntArray(n)
	var res = 0
	while (true) {
		queue[0] = s
		var low = 0
		var high = 1
		prev.fill(-1)
		prev[s] = s
		while (low < high && prev[t] == -1) {
			val v = queue[low]
			low++
			for (u in 0 until n) {
				if (prev[u] != -1 || f[v][u] == c[v][u]) {
					continue
				}
				prev[u] = v
				queue[high] = u
				high++
			}
		}
		if (prev[t] == -1) {
			break
		}
		var flow = Int.MAX_VALUE
		var u = t
		while (u != s) {
			flow = minOf(flow, c[prev[u]][u] - f[prev[u]][u])
			u = prev[u]
		}
		u = t
		while (u != s) {
			f[prev[u]][u] += flow
			f[u][prev[u]] -= flow
			u = prev[u]
		}
		res += flow
	}
	return res
}

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

private val isOnlineJudge = System.getProperty("ONLINE_JUDGE") == "true"
@Suppress("unused")
private val stdStreams = (false to false).apply { if (!isOnlineJudge) {
	if (!first) System.setIn(java.io.File("input.txt").inputStream())
	if (!second) System.setOut(java.io.PrintStream("output.txt"))
}}
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "c.kt"
public final class facebook.y2019.round1.CKt$solve$Ladder {
  private final int id;

  private final int x;

  private final int yFrom;

  private final int yTo;

  public facebook.y2019.round1.CKt$solve$Ladder(int, int, int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field id:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field x:I
      14: aload_0
      15: iload_3
      16: putfield      #19                 // Field yFrom:I
      19: aload_0
      20: iload         4
      22: putfield      #22                 // Field yTo:I
      25: return

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

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

  public final int getYFrom();
    Code:
       0: aload_0
       1: getfield      #19                 // Field yFrom:I
       4: ireturn

  public final int getYTo();
    Code:
       0: aload_0
       1: getfield      #22                 // Field yTo:I
       4: ireturn

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

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

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #19                 // Field yFrom:I
       4: ireturn

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

  public final facebook.y2019.round1.CKt$solve$Ladder copy(int, int, int, int);
    Code:
       0: new           #2                  // class facebook/y2019/round1/CKt$solve$Ladder
       3: dup
       4: iload_1
       5: iload_2
       6: iload_3
       7: iload         4
       9: invokespecial #37                 // Method "<init>":(IIII)V
      12: areturn

  public static facebook.y2019.round1.CKt$solve$Ladder copy$default(facebook.y2019.round1.CKt$solve$Ladder, int, int, int, int, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field id:I
      11: istore_1
      12: iload         5
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field x:I
      23: istore_2
      24: iload         5
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #19                 // Field yFrom:I
      35: istore_3
      36: iload         5
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #22                 // Field yTo:I
      48: istore        4
      50: aload_0
      51: iload_1
      52: iload_2
      53: iload_3
      54: iload         4
      56: invokevirtual #41                 // Method copy:(IIII)Lfacebook/y2019/round1/CKt$solve$Ladder;
      59: areturn

  public java.lang.String toString();
    Code:
       0: new           #45                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #48                 // String Ladder(id=
       9: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field id:I
      16: invokevirtual #55                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #57                 // String , x=
      21: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field x:I
      28: invokevirtual #55                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #59                 // String , yFrom=
      33: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #19                 // Field yFrom:I
      40: invokevirtual #55                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: ldc           #61                 // String , yTo=
      45: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #22                 // Field yTo:I
      52: invokevirtual #55                 // 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 #66                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field id:I
       4: invokestatic  #72                 // 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 x:I
      16: invokestatic  #72                 // 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      #19                 // Field yFrom:I
      29: invokestatic  #72                 // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #22                 // Field yTo:I
      42: invokestatic  #72                 // 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 facebook/y2019/round1/CKt$solve$Ladder
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class facebook/y2019/round1/CKt$solve$Ladder
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field id:I
      25: aload_2
      26: getfield      #13                 // Field id:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field x:I
      38: aload_2
      39: getfield      #16                 // Field x:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #19                 // Field yFrom:I
      51: aload_2
      52: getfield      #19                 // Field yFrom:I
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: aload_0
      61: getfield      #22                 // Field yTo:I
      64: aload_2
      65: getfield      #22                 // Field yTo:I
      68: if_icmpeq     73
      71: iconst_0
      72: ireturn
      73: iconst_1
      74: ireturn
}

Compiled from "c.kt"
public final class facebook.y2019.round1.CKt {
  private static final boolean isOnlineJudge;

  private static final kotlin.Pair<java.lang.Boolean, java.lang.Boolean> stdStreams;

  private static final int 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 #21                 // 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 #21                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: new           #23                 // class java/util/ArrayList
      35: dup
      36: iload_1
      37: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
      40: astore        4
      42: iconst_0
      43: istore        5
      45: iload         5
      47: iload_1
      48: if_icmpge     147
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        20
      63: iconst_0
      64: istore        8
      66: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      69: astore        9
      71: aload         9
      73: iconst_0
      74: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: checkcast     #18                 // class java/lang/Number
      82: invokevirtual #21                 // Method java/lang/Number.intValue:()I
      85: istore        10
      87: aload         9
      89: iconst_1
      90: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      95: checkcast     #18                 // class java/lang/Number
      98: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     101: istore        11
     103: aload         9
     105: iconst_2
     106: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     111: checkcast     #18                 // class java/lang/Number
     114: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     117: istore        12
     119: new           #29                 // class facebook/y2019/round1/CKt$solve$Ladder
     122: dup
     123: iload         7
     125: iload         10
     127: iload         11
     129: iload         12
     131: invokespecial #32                 // Method facebook/y2019/round1/CKt$solve$Ladder."<init>":(IIII)V
     134: aload         20
     136: swap
     137: invokevirtual #36                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     140: pop
     141: iinc          5, 1
     144: goto          45
     147: aload         4
     149: checkcast     #12                 // class java/util/List
     152: astore_3
     153: iconst_0
     154: istore        5
     156: iload_1
     157: iconst_2
     158: iadd
     159: istore        6
     161: iload         6
     163: anewarray     #38                 // class "[I"
     166: astore        7
     168: iload         5
     170: iload         6
     172: if_icmpge     195
     175: iload         5
     177: istore        8
     179: aload         7
     181: iload         8
     183: iload_1
     184: iconst_2
     185: iadd
     186: newarray       int
     188: aastore
     189: iinc          5, 1
     192: goto          168
     195: aload         7
     197: astore        4
     199: aload_3
     200: checkcast     #40                 // class java/lang/Iterable
     203: astore        6
     205: iconst_0
     206: istore        7
     208: aload         6
     210: astore        8
     212: new           #23                 // class java/util/ArrayList
     215: dup
     216: invokespecial #43                 // Method java/util/ArrayList."<init>":()V
     219: checkcast     #45                 // class java/util/Collection
     222: astore        9
     224: iconst_0
     225: istore        10
     227: aload         8
     229: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     234: astore        11
     236: aload         11
     238: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     243: ifeq          316
     246: aload         11
     248: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     253: astore        12
     255: aload         12
     257: checkcast     #29                 // class facebook/y2019/round1/CKt$solve$Ladder
     260: astore        13
     262: iconst_0
     263: istore        14
     265: iconst_2
     266: anewarray     #61                 // class java/lang/Integer
     269: astore        15
     271: aload         15
     273: iconst_0
     274: aload         13
     276: invokevirtual #64                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYFrom:()I
     279: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     282: aastore
     283: aload         15
     285: iconst_1
     286: aload         13
     288: invokevirtual #71                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYTo:()I
     291: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     294: aastore
     295: aload         15
     297: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     300: checkcast     #40                 // class java/lang/Iterable
     303: astore        13
     305: aload         9
     307: aload         13
     309: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     312: pop
     313: goto          236
     316: aload         9
     318: checkcast     #12                 // class java/util/List
     321: nop
     322: checkcast     #40                 // class java/lang/Iterable
     325: invokestatic  #85                 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     328: checkcast     #40                 // class java/lang/Iterable
     331: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     334: astore        5
     336: aload         5
     338: checkcast     #40                 // class java/lang/Iterable
     341: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
     344: invokeinterface #93,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     349: astore        6
     351: aload         6
     353: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     358: ifeq          753
     361: aload         6
     363: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     368: checkcast     #95                 // class kotlin/Pair
     371: astore        7
     373: aload         7
     375: invokevirtual #98                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     378: checkcast     #18                 // class java/lang/Number
     381: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     384: istore        8
     386: aload         7
     388: invokevirtual #101                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     391: checkcast     #18                 // class java/lang/Number
     394: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     397: istore        9
     399: aload_3
     400: checkcast     #40                 // class java/lang/Iterable
     403: astore        11
     405: iconst_0
     406: istore        12
     408: aload         11
     410: astore        13
     412: new           #23                 // class java/util/ArrayList
     415: dup
     416: invokespecial #43                 // Method java/util/ArrayList."<init>":()V
     419: checkcast     #45                 // class java/util/Collection
     422: astore        14
     424: iconst_0
     425: istore        15
     427: aload         13
     429: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     434: astore        16
     436: aload         16
     438: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     443: ifeq          506
     446: aload         16
     448: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     453: astore        17
     455: aload         17
     457: checkcast     #29                 // class facebook/y2019/round1/CKt$solve$Ladder
     460: astore        18
     462: iconst_0
     463: istore        19
     465: aload         18
     467: invokevirtual #64                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYFrom:()I
     470: iload         8
     472: if_icmpgt     489
     475: iload         8
     477: aload         18
     479: invokevirtual #71                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYTo:()I
     482: if_icmpge     489
     485: iconst_1
     486: goto          490
     489: iconst_0
     490: ifeq          436
     493: aload         14
     495: aload         17
     497: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     502: pop
     503: goto          436
     506: aload         14
     508: checkcast     #12                 // class java/util/List
     511: nop
     512: checkcast     #40                 // class java/lang/Iterable
     515: astore        11
     517: nop
     518: iconst_0
     519: istore        12
     521: aload         11
     523: new           #104                // class facebook/y2019/round1/CKt$solve$$inlined$sortedBy$1
     526: dup
     527: invokespecial #105                // Method facebook/y2019/round1/CKt$solve$$inlined$sortedBy$1."<init>":()V
     530: checkcast     #107                // class java/util/Comparator
     533: invokestatic  #111                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     536: checkcast     #40                 // class java/lang/Iterable
     539: astore        11
     541: nop
     542: iconst_0
     543: istore        12
     545: aload         11
     547: astore        13
     549: new           #23                 // class java/util/ArrayList
     552: dup
     553: aload         11
     555: bipush        10
     557: invokestatic  #115                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     560: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     563: checkcast     #45                 // class java/util/Collection
     566: astore        14
     568: iconst_0
     569: istore        15
     571: aload         13
     573: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     578: astore        16
     580: aload         16
     582: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     587: ifeq          633
     590: aload         16
     592: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     597: astore        17
     599: aload         14
     601: aload         17
     603: checkcast     #29                 // class facebook/y2019/round1/CKt$solve$Ladder
     606: astore        18
     608: astore        20
     610: iconst_0
     611: istore        19
     613: aload         18
     615: invokevirtual #118                // Method facebook/y2019/round1/CKt$solve$Ladder.getId:()I
     618: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     621: aload         20
     623: swap
     624: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     629: pop
     630: goto          580
     633: aload         14
     635: checkcast     #12                 // class java/util/List
     638: nop
     639: astore        10
     641: aload         10
     643: checkcast     #40                 // class java/lang/Iterable
     646: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
     649: invokeinterface #93,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     654: astore        11
     656: aload         11
     658: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     663: ifeq          351
     666: aload         11
     668: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     673: checkcast     #95                 // class kotlin/Pair
     676: astore        12
     678: aload         12
     680: invokevirtual #98                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     683: checkcast     #18                 // class java/lang/Number
     686: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     689: istore        13
     691: aload         12
     693: invokevirtual #101                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     696: checkcast     #18                 // class java/lang/Number
     699: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     702: istore        14
     704: aload         4
     706: iload         13
     708: aaload
     709: astore        15
     711: aload         15
     713: iload         14
     715: aload         15
     717: iload         14
     719: iaload
     720: iload         9
     722: iload         8
     724: isub
     725: iadd
     726: iastore
     727: aload         4
     729: iload         14
     731: aaload
     732: astore        15
     734: aload         15
     736: iload         13
     738: aload         15
     740: iload         13
     742: iaload
     743: iload         9
     745: iload         8
     747: isub
     748: iadd
     749: iastore
     750: goto          656
     753: iload_1
     754: iload_2
     755: imul
     756: istore        6
     758: aload_3
     759: checkcast     #40                 // class java/lang/Iterable
     762: astore        7
     764: iconst_0
     765: istore        8
     767: aload         7
     769: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     774: astore        9
     776: aload         9
     778: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     783: ifeq          853
     786: aload         9
     788: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     793: astore        10
     795: aload         10
     797: checkcast     #29                 // class facebook/y2019/round1/CKt$solve$Ladder
     800: astore        11
     802: iconst_0
     803: istore        12
     805: aload         11
     807: invokevirtual #64                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYFrom:()I
     810: ifne          825
     813: aload         4
     815: iload_1
     816: aaload
     817: aload         11
     819: invokevirtual #118                // Method facebook/y2019/round1/CKt$solve$Ladder.getId:()I
     822: iload         6
     824: iastore
     825: aload         11
     827: invokevirtual #71                 // Method facebook/y2019/round1/CKt$solve$Ladder.getYTo:()I
     830: iload_2
     831: if_icmpne     848
     834: aload         4
     836: aload         11
     838: invokevirtual #118                // Method facebook/y2019/round1/CKt$solve$Ladder.getId:()I
     841: aaload
     842: iload_1
     843: iconst_1
     844: iadd
     845: iload         6
     847: iastore
     848: nop
     849: nop
     850: goto          776
     853: nop
     854: aload         4
     856: iload_1
     857: iload_1
     858: iconst_1
     859: iadd
     860: invokestatic  #122                // Method edmonsKarp:([[III)I
     863: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     866: astore        8
     868: aload         8
     870: checkcast     #18                 // class java/lang/Number
     873: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     876: istore        9
     878: iconst_0
     879: istore        10
     881: iload         9
     883: iload         6
     885: if_icmpge     892
     888: iconst_1
     889: goto          893
     892: iconst_0
     893: ifeq          901
     896: aload         8
     898: goto          902
     901: aconst_null
     902: dup
     903: ifnull        912
     906: invokevirtual #123                // Method java/lang/Integer.intValue:()I
     909: goto          914
     912: pop
     913: iconst_m1
     914: ireturn

  public static final int edmonsKarp(int[][], int, int);
    Code:
       0: aload_0
       1: ldc           #176                // String c
       3: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #184                // class "[Ljava/lang/Object;"
      10: arraylength
      11: istore_3
      12: iconst_0
      13: istore        5
      15: iload_3
      16: anewarray     #38                 // class "[I"
      19: astore        6
      21: iload         5
      23: iload_3
      24: if_icmpge     45
      27: iload         5
      29: istore        7
      31: aload         6
      33: iload         7
      35: iload_3
      36: newarray       int
      38: aastore
      39: iinc          5, 1
      42: goto          21
      45: aload         6
      47: astore        4
      49: iload_3
      50: newarray       int
      52: astore        5
      54: iload_3
      55: newarray       int
      57: astore        6
      59: iconst_0
      60: istore        7
      62: nop
      63: aload         5
      65: iconst_0
      66: iload_1
      67: iastore
      68: iconst_0
      69: istore        8
      71: iconst_1
      72: istore        9
      74: aload         6
      76: iconst_m1
      77: iconst_0
      78: iconst_0
      79: bipush        6
      81: aconst_null
      82: invokestatic  #190                // Method kotlin/collections/ArraysKt.fill$default:([IIIIILjava/lang/Object;)V
      85: aload         6
      87: iload_1
      88: iload_1
      89: iastore
      90: iload         8
      92: iload         9
      94: if_icmpge     177
      97: aload         6
      99: iload_2
     100: iaload
     101: iconst_m1
     102: if_icmpne     177
     105: aload         5
     107: iload         8
     109: iaload
     110: istore        10
     112: iinc          8, 1
     115: iconst_0
     116: istore        11
     118: iload         11
     120: iload_3
     121: if_icmpge     90
     124: aload         6
     126: iload         11
     128: iaload
     129: iconst_m1
     130: if_icmpne     151
     133: aload         4
     135: iload         10
     137: aaload
     138: iload         11
     140: iaload
     141: aload_0
     142: iload         10
     144: aaload
     145: iload         11
     147: iaload
     148: if_icmpne     154
     151: goto          171
     154: aload         6
     156: iload         11
     158: iload         10
     160: iastore
     161: aload         5
     163: iload         9
     165: iload         11
     167: iastore
     168: iinc          9, 1
     171: iinc          11, 1
     174: goto          118
     177: aload         6
     179: iload_2
     180: iaload
     181: iconst_m1
     182: if_icmpne     188
     185: goto          323
     188: ldc           #191                // int 2147483647
     190: istore        10
     192: iload_2
     193: istore        11
     195: iload         11
     197: iload_1
     198: if_icmpeq     240
     201: iload         10
     203: aload_0
     204: aload         6
     206: iload         11
     208: iaload
     209: aaload
     210: iload         11
     212: iaload
     213: aload         4
     215: aload         6
     217: iload         11
     219: iaload
     220: aaload
     221: iload         11
     223: iaload
     224: isub
     225: invokestatic  #197                // Method java/lang/Math.min:(II)I
     228: istore        10
     230: aload         6
     232: iload         11
     234: iaload
     235: istore        11
     237: goto          195
     240: iload_2
     241: istore        11
     243: iload         11
     245: iload_1
     246: if_icmpeq     313
     249: aload         4
     251: aload         6
     253: iload         11
     255: iaload
     256: aaload
     257: astore        12
     259: iload         11
     261: istore        13
     263: aload         12
     265: iload         13
     267: aload         12
     269: iload         13
     271: iaload
     272: iload         10
     274: iadd
     275: iastore
     276: aload         4
     278: iload         11
     280: aaload
     281: astore        12
     283: aload         6
     285: iload         11
     287: iaload
     288: istore        13
     290: aload         12
     292: iload         13
     294: aload         12
     296: iload         13
     298: iaload
     299: iload         10
     301: isub
     302: iastore
     303: aload         6
     305: iload         11
     307: iaload
     308: istore        11
     310: goto          243
     313: iload         7
     315: iload         10
     317: iadd
     318: istore        7
     320: goto          62
     323: iload         7
     325: ireturn

  public static final void main();
    Code:
       0: invokestatic  #212                // 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           #214                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #215                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #217                // String Case #
      24: invokevirtual #221                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #224                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #226                // String :
      35: invokevirtual #221                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #228                // Method solve:()I
      41: invokevirtual #224                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      44: invokevirtual #232                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #238                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #244                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static void getStdStreams$annotations();
    Code:
       0: return

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

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #257                // Method readLn:()Ljava/lang/String;
       3: checkcast     #265                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #267                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc_w         #269                // String
      16: aastore
      17: aload_0
      18: iconst_0
      19: iconst_0
      20: bipush        6
      22: aconst_null
      23: invokestatic  #275                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      26: areturn

  private static final java.util.List<java.lang.Integer> readInts();
    Code:
       0: invokestatic  #278                // Method readStrings:()Ljava/util/List;
       3: checkcast     #40                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #23                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #115                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #45                 // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #267                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #102,  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  #283                // Method main:()V
       3: return

  static {};
    Code:
       0: ldc_w         #288                // String ONLINE_JUDGE
       3: invokestatic  #292                // Method java/lang/System.getProperty:(Ljava/lang/String;)Ljava/lang/String;
       6: ldc_w         #294                // String true
       9: invokestatic  #298                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      12: putstatic     #302                // Field isOnlineJudge:Z
      15: iconst_0
      16: invokestatic  #307                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      19: iconst_0
      20: invokestatic  #307                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      23: invokestatic  #313                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      26: astore_0
      27: aload_0
      28: astore_1
      29: iconst_0
      30: istore_2
      31: getstatic     #302                // Field isOnlineJudge:Z
      34: ifne          99
      37: aload_1
      38: invokevirtual #316                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      41: checkcast     #304                // class java/lang/Boolean
      44: invokevirtual #319                // Method java/lang/Boolean.booleanValue:()Z
      47: ifne          73
      50: new           #321                // class java/io/FileInputStream
      53: dup
      54: new           #323                // class java/io/File
      57: dup
      58: ldc_w         #325                // String input.txt
      61: invokespecial #328                // Method java/io/File."<init>":(Ljava/lang/String;)V
      64: invokespecial #331                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      67: checkcast     #333                // class java/io/InputStream
      70: invokestatic  #337                // Method java/lang/System.setIn:(Ljava/io/InputStream;)V
      73: aload_1
      74: invokevirtual #340                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      77: checkcast     #304                // class java/lang/Boolean
      80: invokevirtual #319                // Method java/lang/Boolean.booleanValue:()Z
      83: ifne          99
      86: new           #240                // class java/io/PrintStream
      89: dup
      90: ldc_w         #342                // String output.txt
      93: invokespecial #343                // Method java/io/PrintStream."<init>":(Ljava/lang/String;)V
      96: invokestatic  #347                // Method java/lang/System.setOut:(Ljava/io/PrintStream;)V
      99: nop
     100: aload_0
     101: putstatic     #351                // Field stdStreams:Lkotlin/Pair;
     104: return
}

Compiled from "Comparisons.kt"
public final class facebook.y2019.round1.CKt$solve$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public facebook.y2019.round1.CKt$solve$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class facebook/y2019/round1/CKt$solve$Ladder
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method facebook/y2019/round1/CKt$solve$Ladder.getX:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class facebook/y2019/round1/CKt$solve$Ladder
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method facebook/y2019/round1/CKt$solve$Ladder.getX:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}


package facebook.y2019.round1

private const val INF = Int.MAX_VALUE / 3

private fun solve(): String {
	val (n, m) = readInts()
	val edgesInput = List(m) { readInts() }
	val graph = Array(n) { IntArray(n) { INF } }
	for ((aInput, bInput, d) in edgesInput) {
		val a = aInput - 1
		val b = bInput - 1
		graph[a][b] = d
		graph[b][a] = d
	}
	val e = graph.copy()
	for (k in 0 until n) {
		for (i in 0 until n) {
			for (j in 0 until n) {
				e[i][j] = minOf(e[i][j], e[i][k] + e[k][j])
				if ((e[i][j] < graph[i][j]) && (graph[i][j] < INF)) { return "Impossible" }
			}
		}
	}
	return "$m\n${edgesInput.joinToString("\n") { it.joinToString(" ") }}"
}

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

private fun Array<IntArray>.copy() = Array(size) { get(it).clone() }

private val isOnlineJudge = System.getProperty("ONLINE_JUDGE") == "true"
@Suppress("unused")
private val stdStreams = (false to false).apply { if (!isOnlineJudge) {
	print(java.io.File(".").canonicalPath)
	if (!first) System.setIn(java.io.File("input.txt").inputStream())
	if (!second) System.setOut(java.io.PrintStream("output.txt"))
}}
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 facebook.y2019.round1.AKt {
  private static final int INF;

  private static final boolean isOnlineJudge;

  private static final kotlin.Pair<java.lang.Boolean, java.lang.Boolean> stdStreams;

  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: 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        12
      63: iconst_0
      64: istore        8
      66: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      69: aload         12
      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: iconst_0
      89: istore        5
      91: iload_1
      92: anewarray     #34                 // class "[I"
      95: astore        6
      97: iload         5
      99: iload_1
     100: if_icmpge     159
     103: iload         5
     105: istore        7
     107: aload         6
     109: iload         7
     111: iconst_0
     112: istore        8
     114: iload_1
     115: newarray       int
     117: astore        9
     119: istore        13
     121: astore        12
     123: iload         8
     125: iload_1
     126: if_icmpge     146
     129: iload         8
     131: istore        10
     133: aload         9
     135: iload         10
     137: ldc           #35                 // int 715827882
     139: iastore
     140: iinc          8, 1
     143: goto          123
     146: aload         12
     148: iload         13
     150: aload         9
     152: aastore
     153: iinc          5, 1
     156: goto          97
     159: aload         6
     161: astore        4
     163: aload_3
     164: invokeinterface #39,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     169: astore        5
     171: aload         5
     173: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          276
     181: aload         5
     183: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: checkcast     #12                 // class java/util/List
     191: astore        6
     193: aload         6
     195: iconst_0
     196: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     201: checkcast     #18                 // class java/lang/Number
     204: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     207: istore        7
     209: aload         6
     211: iconst_1
     212: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     217: checkcast     #18                 // class java/lang/Number
     220: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     223: istore        8
     225: aload         6
     227: iconst_2
     228: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     233: checkcast     #18                 // class java/lang/Number
     236: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     239: istore        9
     241: iload         7
     243: iconst_1
     244: isub
     245: istore        10
     247: iload         8
     249: iconst_1
     250: isub
     251: istore        11
     253: aload         4
     255: iload         10
     257: aaload
     258: iload         11
     260: iload         9
     262: iastore
     263: aload         4
     265: iload         11
     267: aaload
     268: iload         10
     270: iload         9
     272: iastore
     273: goto          171
     276: aload         4
     278: invokestatic  #53                 // Method copy:([[I)[[I
     281: astore        5
     283: iconst_0
     284: istore        6
     286: iload         6
     288: iload_1
     289: if_icmpge     399
     292: iconst_0
     293: istore        7
     295: iload         7
     297: iload_1
     298: if_icmpge     393
     301: iconst_0
     302: istore        8
     304: iload         8
     306: iload_1
     307: if_icmpge     387
     310: aload         5
     312: iload         7
     314: aaload
     315: iload         8
     317: aload         5
     319: iload         7
     321: aaload
     322: iload         8
     324: iaload
     325: aload         5
     327: iload         7
     329: aaload
     330: iload         6
     332: iaload
     333: aload         5
     335: iload         6
     337: aaload
     338: iload         8
     340: iaload
     341: iadd
     342: invokestatic  #59                 // Method java/lang/Math.min:(II)I
     345: iastore
     346: aload         5
     348: iload         7
     350: aaload
     351: iload         8
     353: iaload
     354: aload         4
     356: iload         7
     358: aaload
     359: iload         8
     361: iaload
     362: if_icmpge     381
     365: aload         4
     367: iload         7
     369: aaload
     370: iload         8
     372: iaload
     373: ldc           #35                 // int 715827882
     375: if_icmpge     381
     378: ldc           #61                 // String Impossible
     380: areturn
     381: iinc          8, 1
     384: goto          304
     387: iinc          7, 1
     390: goto          295
     393: iinc          6, 1
     396: goto          286
     399: new           #63                 // class java/lang/StringBuilder
     402: dup
     403: invokespecial #66                 // Method java/lang/StringBuilder."<init>":()V
     406: iload_2
     407: invokevirtual #70                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     410: bipush        10
     412: invokevirtual #73                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     415: aload_3
     416: checkcast     #75                 // class java/lang/Iterable
     419: ldc           #77                 // String \n
     421: checkcast     #79                 // class java/lang/CharSequence
     424: aconst_null
     425: aconst_null
     426: iconst_0
     427: aconst_null
     428: invokedynamic #98,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     433: bipush        30
     435: aconst_null
     436: invokestatic  #104                // 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;
     439: invokevirtual #107                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     442: invokevirtual #110                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     445: areturn

  public static final void main();
    Code:
       0: invokestatic  #133                // 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           #63                 // class java/lang/StringBuilder
      18: dup
      19: invokespecial #66                 // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #135                // String Case #
      24: invokevirtual #107                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #70                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #137                // String :
      35: invokevirtual #107                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #139                // Method solve:()Ljava/lang/String;
      41: invokevirtual #107                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: invokevirtual #110                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #145                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #151                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static final int[][] copy(int[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: checkcast     #154                // class "[Ljava/lang/Object;"
       6: arraylength
       7: istore_2
       8: iload_2
       9: anewarray     #34                 // class "[I"
      12: astore_3
      13: iload_1
      14: iload_2
      15: if_icmpge     38
      18: iload_1
      19: istore        4
      21: aload_3
      22: iload         4
      24: aload_0
      25: iload         4
      27: aaload
      28: invokevirtual #157                // Method java/lang/Object.clone:()Ljava/lang/Object;
      31: aastore
      32: iinc          1, 1
      35: goto          13
      38: aload_3
      39: areturn

  private static void getStdStreams$annotations();
    Code:
       0: return

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

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

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

  private static final java.lang.CharSequence solve$lambda$1(java.util.List);
    Code:
       0: aload_0
       1: ldc           #222                // String it
       3: invokestatic  #226                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #75                 // class java/lang/Iterable
      10: ldc           #184                // String
      12: checkcast     #79                 // class java/lang/CharSequence
      15: aconst_null
      16: aconst_null
      17: iconst_0
      18: aconst_null
      19: aconst_null
      20: bipush        62
      22: aconst_null
      23: invokestatic  #104                // 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;
      26: checkcast     #79                 // class java/lang/CharSequence
      29: areturn

  static {};
    Code:
       0: ldc           #229                // String ONLINE_JUDGE
       2: invokestatic  #233                // Method java/lang/System.getProperty:(Ljava/lang/String;)Ljava/lang/String;
       5: ldc           #235                // String true
       7: invokestatic  #239                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      10: putstatic     #243                // Field isOnlineJudge:Z
      13: iconst_0
      14: invokestatic  #248                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      17: iconst_0
      18: invokestatic  #248                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      21: invokestatic  #254                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      24: astore_0
      25: aload_0
      26: astore_1
      27: iconst_0
      28: istore_2
      29: getstatic     #243                // Field isOnlineJudge:Z
      32: ifne          117
      35: new           #256                // class java/io/File
      38: dup
      39: ldc_w         #258                // String .
      42: invokespecial #261                // Method java/io/File."<init>":(Ljava/lang/String;)V
      45: invokevirtual #264                // Method java/io/File.getCanonicalPath:()Ljava/lang/String;
      48: getstatic     #145                // Field java/lang/System.out:Ljava/io/PrintStream;
      51: swap
      52: invokevirtual #267                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      55: aload_1
      56: invokevirtual #272                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      59: checkcast     #245                // class java/lang/Boolean
      62: invokevirtual #275                // Method java/lang/Boolean.booleanValue:()Z
      65: ifne          91
      68: new           #277                // class java/io/FileInputStream
      71: dup
      72: new           #256                // class java/io/File
      75: dup
      76: ldc_w         #279                // String input.txt
      79: invokespecial #261                // Method java/io/File."<init>":(Ljava/lang/String;)V
      82: invokespecial #282                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      85: checkcast     #284                // class java/io/InputStream
      88: invokestatic  #288                // Method java/lang/System.setIn:(Ljava/io/InputStream;)V
      91: aload_1
      92: invokevirtual #291                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      95: checkcast     #245                // class java/lang/Boolean
      98: invokevirtual #275                // Method java/lang/Boolean.booleanValue:()Z
     101: ifne          117
     104: new           #147                // class java/io/PrintStream
     107: dup
     108: ldc_w         #293                // String output.txt
     111: invokespecial #294                // Method java/io/PrintStream."<init>":(Ljava/lang/String;)V
     114: invokestatic  #298                // Method java/lang/System.setOut:(Ljava/io/PrintStream;)V
     117: nop
     118: aload_0
     119: putstatic     #302                // Field stdStreams:Lkotlin/Pair;
     122: return
}


package facebook.y2019.round1

private fun solve(): Int {
	val (n, h, v) = readInts()
	val (x, y) = List(2) {
		val (x1, x2, ax, bx, cx, dx) = readInts()
		val x = IntArray(n)
		x[0] = x1
		x[1] = x2
		for (i in 2 until n) {
			x[i] = ((ax * 1L * x[i - 2] + bx * 1L * x[i - 1] + cx) % dx + 1).toInt()
		}
		x
	}
	val sorted = listOf(x to y, y to x).map { (x, y) ->
		val longs = List(n) { (x[it].toLong() shl 32) + y[it].toLong() }.sorted()
		longs.map { (it shr 32).toInt() } to longs.map { it.toInt() }
	}
	return if (h + v < n) -1 else List(2) { t ->
		solveVertical(sorted[t].second, sorted[t].first, sorted[1 - t].first, listOf(h, v)[t])
	}.minOrNull()!!
}

fun solveVertical(x: List<Int>, y: List<Int>, xSorted: List<Int>, v: Int): Int {
	val n = x.size
	var ans = y.last() + if (v < n) xSorted.last() else 0
	val xAffordable = xSorted.getOrElse(n - v - 1) { 0 }
	var xMaxAbove = 0
	var xMax = 0
	for (i in n - 1 downTo 0) {
		xMax = maxOf(xMax, x[i])
		if (i > 0 && y[i] == y[i - 1]) continue
		if (xMaxAbove <= xMax) {
			ans = minOf(ans, y[i] + maxOf(xAffordable, xMaxAbove))
			xMaxAbove = xMax
		}
		if (i < v) break
		xMax = 0
	}
	return ans
}

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

private operator fun <T> List<T>.component6(): T { return get(5) }

private val isOnlineJudge = System.getProperty("ONLINE_JUDGE") == "true"
@Suppress("unused")
private val stdStreams = (false to false).apply { if (!isOnlineJudge) {
	if (!first) System.setIn(java.io.File("input.txt").inputStream())
	if (!second) System.setOut(java.io.PrintStream("output.txt"))
}}
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Compiled from "d.kt"
public final class facebook.y2019.round1.DKt {
  private static final boolean isOnlineJudge;

  private static final kotlin.Pair<java.lang.Boolean, java.lang.Boolean> stdStreams;

  private static final int 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 #21                 // 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 #21                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: aload_0
      33: iconst_2
      34: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      39: checkcast     #18                 // class java/lang/Number
      42: invokevirtual #21                 // Method java/lang/Number.intValue:()I
      45: istore_3
      46: iconst_2
      47: istore        5
      49: new           #23                 // class java/util/ArrayList
      52: dup
      53: iload         5
      55: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
      58: astore        6
      60: iconst_0
      61: istore        7
      63: iload         7
      65: iload         5
      67: if_icmpge     275
      70: iload         7
      72: istore        8
      74: aload         6
      76: iload         8
      78: istore        9
      80: astore        32
      82: iconst_0
      83: istore        10
      85: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      88: astore        11
      90: aload         11
      92: iconst_0
      93: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      98: checkcast     #18                 // class java/lang/Number
     101: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     104: istore        12
     106: aload         11
     108: iconst_1
     109: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     114: checkcast     #18                 // class java/lang/Number
     117: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     120: istore        13
     122: aload         11
     124: iconst_2
     125: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #18                 // class java/lang/Number
     133: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     136: istore        14
     138: aload         11
     140: iconst_3
     141: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     146: checkcast     #18                 // class java/lang/Number
     149: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     152: istore        15
     154: aload         11
     156: iconst_4
     157: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     162: checkcast     #18                 // class java/lang/Number
     165: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     168: istore        16
     170: aload         11
     172: invokestatic  #31                 // Method component6:(Ljava/util/List;)Ljava/lang/Object;
     175: checkcast     #18                 // class java/lang/Number
     178: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     181: istore        17
     183: iload_1
     184: newarray       int
     186: astore        18
     188: aload         18
     190: iconst_0
     191: iload         12
     193: iastore
     194: aload         18
     196: iconst_1
     197: iload         13
     199: iastore
     200: iconst_2
     201: istore        19
     203: iload         19
     205: iload_1
     206: if_icmpge     260
     209: aload         18
     211: iload         19
     213: iload         14
     215: i2l
     216: lconst_1
     217: lmul
     218: aload         18
     220: iload         19
     222: iconst_2
     223: isub
     224: iaload
     225: i2l
     226: lmul
     227: iload         15
     229: i2l
     230: lconst_1
     231: lmul
     232: aload         18
     234: iload         19
     236: iconst_1
     237: isub
     238: iaload
     239: i2l
     240: lmul
     241: ladd
     242: iload         16
     244: i2l
     245: ladd
     246: iload         17
     248: i2l
     249: lrem
     250: lconst_1
     251: ladd
     252: l2i
     253: iastore
     254: iinc          19, 1
     257: goto          203
     260: aload         18
     262: aload         32
     264: swap
     265: invokevirtual #35                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     268: pop
     269: iinc          7, 1
     272: goto          63
     275: aload         6
     277: checkcast     #12                 // class java/util/List
     280: astore        4
     282: aload         4
     284: iconst_0
     285: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     290: checkcast     #37                 // class "[I"
     293: astore        5
     295: aload         4
     297: iconst_1
     298: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     303: checkcast     #37                 // class "[I"
     306: astore        6
     308: iconst_2
     309: anewarray     #39                 // class kotlin/Pair
     312: astore        8
     314: aload         8
     316: iconst_0
     317: aload         5
     319: aload         6
     321: invokestatic  #45                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     324: aastore
     325: aload         8
     327: iconst_1
     328: aload         6
     330: aload         5
     332: invokestatic  #45                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     335: aastore
     336: aload         8
     338: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     341: checkcast     #53                 // class java/lang/Iterable
     344: astore        8
     346: iconst_0
     347: istore        9
     349: aload         8
     351: astore        10
     353: new           #23                 // class java/util/ArrayList
     356: dup
     357: aload         8
     359: bipush        10
     361: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     364: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     367: checkcast     #59                 // class java/util/Collection
     370: astore        11
     372: iconst_0
     373: istore        12
     375: aload         10
     377: invokeinterface #63,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     382: astore        13
     384: aload         13
     386: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     391: ifeq          749
     394: aload         13
     396: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     401: astore        14
     403: aload         11
     405: aload         14
     407: checkcast     #39                 // class kotlin/Pair
     410: astore        15
     412: astore        32
     414: iconst_0
     415: istore        16
     417: aload         15
     419: invokevirtual #76                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     422: checkcast     #37                 // class "[I"
     425: astore        17
     427: aload         15
     429: invokevirtual #79                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     432: checkcast     #37                 // class "[I"
     435: astore        18
     437: new           #23                 // class java/util/ArrayList
     440: dup
     441: iload_1
     442: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     445: astore        19
     447: iconst_0
     448: istore        20
     450: iload         20
     452: iload_1
     453: if_icmpge     503
     456: iload         20
     458: istore        21
     460: aload         19
     462: iload         21
     464: istore        22
     466: astore        23
     468: iconst_0
     469: istore        24
     471: aload         17
     473: iload         22
     475: iaload
     476: i2l
     477: bipush        32
     479: lshl
     480: aload         18
     482: iload         22
     484: iaload
     485: i2l
     486: ladd
     487: invokestatic  #85                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     490: aload         23
     492: swap
     493: invokevirtual #35                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     496: pop
     497: iinc          20, 1
     500: goto          450
     503: aload         19
     505: checkcast     #12                 // class java/util/List
     508: checkcast     #53                 // class java/lang/Iterable
     511: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     514: astore        25
     516: aload         25
     518: checkcast     #53                 // class java/lang/Iterable
     521: astore        19
     523: iconst_0
     524: istore        20
     526: aload         19
     528: astore        21
     530: new           #23                 // class java/util/ArrayList
     533: dup
     534: aload         19
     536: bipush        10
     538: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     541: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     544: checkcast     #59                 // class java/util/Collection
     547: astore        22
     549: iconst_0
     550: istore        24
     552: aload         21
     554: invokeinterface #63,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     559: astore        26
     561: aload         26
     563: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     568: ifeq          618
     571: aload         26
     573: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     578: astore        27
     580: aload         22
     582: aload         27
     584: checkcast     #18                 // class java/lang/Number
     587: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     590: lstore        28
     592: astore        23
     594: iconst_0
     595: istore        30
     597: lload         28
     599: bipush        32
     601: lshr
     602: l2i
     603: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     606: aload         23
     608: swap
     609: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     614: pop
     615: goto          561
     618: aload         22
     620: checkcast     #12                 // class java/util/List
     623: nop
     624: aload         25
     626: checkcast     #53                 // class java/lang/Iterable
     629: astore        19
     631: astore        23
     633: iconst_0
     634: istore        20
     636: aload         19
     638: astore        21
     640: new           #23                 // class java/util/ArrayList
     643: dup
     644: aload         19
     646: bipush        10
     648: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     651: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     654: checkcast     #59                 // class java/util/Collection
     657: astore        22
     659: iconst_0
     660: istore        24
     662: aload         21
     664: invokeinterface #63,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     669: astore        26
     671: aload         26
     673: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     678: ifeq          725
     681: aload         26
     683: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     688: astore        27
     690: aload         22
     692: aload         27
     694: checkcast     #18                 // class java/lang/Number
     697: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     700: lstore        28
     702: astore        31
     704: iconst_0
     705: istore        30
     707: lload         28
     709: l2i
     710: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     713: aload         31
     715: swap
     716: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     721: pop
     722: goto          671
     725: aload         22
     727: checkcast     #12                 // class java/util/List
     730: nop
     731: aload         23
     733: swap
     734: invokestatic  #45                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     737: aload         32
     739: swap
     740: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     745: pop
     746: goto          384
     749: aload         11
     751: checkcast     #12                 // class java/util/List
     754: nop
     755: astore        7
     757: iload_2
     758: iload_3
     759: iadd
     760: iload_1
     761: if_icmpge     768
     764: iconst_m1
     765: goto          943
     768: iconst_2
     769: istore        8
     771: new           #23                 // class java/util/ArrayList
     774: dup
     775: iload         8
     777: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
     780: astore        9
     782: iconst_0
     783: istore        10
     785: iload         10
     787: iload         8
     789: if_icmpge     922
     792: iload         10
     794: istore        11
     796: aload         9
     798: iload         11
     800: istore        12
     802: astore        32
     804: iconst_0
     805: istore        13
     807: aload         7
     809: iload         12
     811: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     816: checkcast     #39                 // class kotlin/Pair
     819: invokevirtual #102                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     822: checkcast     #12                 // class java/util/List
     825: aload         7
     827: iload         12
     829: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     834: checkcast     #39                 // class kotlin/Pair
     837: invokevirtual #105                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     840: checkcast     #12                 // class java/util/List
     843: aload         7
     845: iconst_1
     846: iload         12
     848: isub
     849: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     854: checkcast     #39                 // class kotlin/Pair
     857: invokevirtual #105                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     860: checkcast     #12                 // class java/util/List
     863: iconst_2
     864: anewarray     #95                 // class java/lang/Integer
     867: astore        14
     869: aload         14
     871: iconst_0
     872: iload_2
     873: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     876: aastore
     877: aload         14
     879: iconst_1
     880: iload_3
     881: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     884: aastore
     885: aload         14
     887: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     890: iload         12
     892: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     897: checkcast     #18                 // class java/lang/Number
     900: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     903: invokestatic  #109                // Method solveVertical:(Ljava/util/List;Ljava/util/List;Ljava/util/List;I)I
     906: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     909: aload         32
     911: swap
     912: invokevirtual #35                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     915: pop
     916: iinc          10, 1
     919: goto          785
     922: aload         9
     924: checkcast     #12                 // class java/util/List
     927: checkcast     #53                 // class java/lang/Iterable
     930: invokestatic  #113                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     933: dup
     934: invokestatic  #119                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     937: checkcast     #18                 // class java/lang/Number
     940: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     943: ireturn

  public static final int solveVertical(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #155                // String x
       3: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #160                // String y
       9: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #162                // String xSorted
      15: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: invokeinterface #165,  1          // InterfaceMethod java/util/List.size:()I
      24: istore        4
      26: aload_1
      27: invokestatic  #168                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      30: checkcast     #18                 // class java/lang/Number
      33: invokevirtual #21                 // Method java/lang/Number.intValue:()I
      36: iload_3
      37: iload         4
      39: if_icmpge     55
      42: aload_2
      43: invokestatic  #168                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      46: checkcast     #18                 // class java/lang/Number
      49: invokevirtual #21                 // Method java/lang/Number.intValue:()I
      52: goto          56
      55: iconst_0
      56: iadd
      57: istore        5
      59: aload_2
      60: astore        7
      62: iload         4
      64: iload_3
      65: isub
      66: iconst_1
      67: isub
      68: istore        8
      70: iconst_0
      71: iload         8
      73: if_icmpgt     96
      76: iload         8
      78: aload         7
      80: invokeinterface #165,  1          // InterfaceMethod java/util/List.size:()I
      85: if_icmpge     92
      88: iconst_1
      89: goto          97
      92: iconst_0
      93: goto          97
      96: iconst_0
      97: ifeq          112
     100: aload         7
     102: iload         8
     104: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     109: goto          124
     112: iload         8
     114: istore        9
     116: iconst_0
     117: istore        10
     119: iconst_0
     120: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     123: nop
     124: checkcast     #18                 // class java/lang/Number
     127: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     130: istore        6
     132: iconst_0
     133: istore        7
     135: iconst_0
     136: istore        8
     138: iload         4
     140: iconst_1
     141: isub
     142: istore        9
     144: iconst_m1
     145: iload         9
     147: if_icmpge     264
     150: iload         8
     152: aload_0
     153: iload         9
     155: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     160: checkcast     #18                 // class java/lang/Number
     163: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     166: invokestatic  #174                // Method java/lang/Math.max:(II)I
     169: istore        8
     171: iload         9
     173: ifle          209
     176: aload_1
     177: iload         9
     179: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     184: checkcast     #18                 // class java/lang/Number
     187: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     190: aload_1
     191: iload         9
     193: iconst_1
     194: isub
     195: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     200: checkcast     #18                 // class java/lang/Number
     203: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     206: if_icmpeq     258
     209: iload         7
     211: iload         8
     213: if_icmpgt     249
     216: iload         5
     218: aload_1
     219: iload         9
     221: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     226: checkcast     #18                 // class java/lang/Number
     229: invokevirtual #21                 // Method java/lang/Number.intValue:()I
     232: iload         6
     234: iload         7
     236: invokestatic  #174                // Method java/lang/Math.max:(II)I
     239: iadd
     240: invokestatic  #177                // Method java/lang/Math.min:(II)I
     243: istore        5
     245: iload         8
     247: istore        7
     249: iload         9
     251: iload_3
     252: if_icmplt     264
     255: iconst_0
     256: istore        8
     258: iinc          9, -1
     261: goto          144
     264: iload         5
     266: ireturn

  public static final void main();
    Code:
       0: invokestatic  #187                // 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           #189                // class java/lang/StringBuilder
      18: dup
      19: invokespecial #191                // Method java/lang/StringBuilder."<init>":()V
      22: ldc           #193                // String Case #
      24: invokevirtual #197                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: iload_2
      28: iconst_1
      29: iadd
      30: invokevirtual #200                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      33: ldc           #202                // String :
      35: invokevirtual #197                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: invokestatic  #204                // Method solve:()I
      41: invokevirtual #200                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      44: invokevirtual #208                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      47: getstatic     #214                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #219                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          1, 1
      58: goto          6
      61: return

  private static final <T> T component6(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #223                // String <this>
       3: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_5
       8: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: areturn

  private static void getStdStreams$annotations();
    Code:
       0: return

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

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

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

  static {};
    Code:
       0: ldc_w         #264                // String ONLINE_JUDGE
       3: invokestatic  #268                // Method java/lang/System.getProperty:(Ljava/lang/String;)Ljava/lang/String;
       6: ldc_w         #270                // String true
       9: invokestatic  #274                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      12: putstatic     #278                // Field isOnlineJudge:Z
      15: iconst_0
      16: invokestatic  #283                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      19: iconst_0
      20: invokestatic  #283                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      23: invokestatic  #45                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      26: astore_0
      27: aload_0
      28: astore_1
      29: iconst_0
      30: istore_2
      31: getstatic     #278                // Field isOnlineJudge:Z
      34: ifne          99
      37: aload_1
      38: invokevirtual #105                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      41: checkcast     #280                // class java/lang/Boolean
      44: invokevirtual #286                // Method java/lang/Boolean.booleanValue:()Z
      47: ifne          73
      50: new           #288                // class java/io/FileInputStream
      53: dup
      54: new           #290                // class java/io/File
      57: dup
      58: ldc_w         #292                // String input.txt
      61: invokespecial #295                // Method java/io/File."<init>":(Ljava/lang/String;)V
      64: invokespecial #298                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      67: checkcast     #300                // class java/io/InputStream
      70: invokestatic  #304                // Method java/lang/System.setIn:(Ljava/io/InputStream;)V
      73: aload_1
      74: invokevirtual #102                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      77: checkcast     #280                // class java/lang/Boolean
      80: invokevirtual #286                // Method java/lang/Boolean.booleanValue:()Z
      83: ifne          99
      86: new           #216                // class java/io/PrintStream
      89: dup
      90: ldc_w         #306                // String output.txt
      93: invokespecial #307                // Method java/io/PrintStream."<init>":(Ljava/lang/String;)V
      96: invokestatic  #311                // Method java/lang/System.setOut:(Ljava/io/PrintStream;)V
      99: nop
     100: aload_0
     101: putstatic     #315                // Field stdStreams:Lkotlin/Pair;
     104: return
}