package codeforces.round773

private fun solve() {
	readInt()
	val a = readInts().toIntArray()
	val groups = a.groupBy { it }
	if (groups.values.any { it.size % 2 != 0 }) return println(-1)
	var start = 0
	val insertions = mutableListOf<Pair<Int, Int>>()
	val tandems = mutableListOf<Int>()
	var x = 0
	while (start < a.size) {
		val repeat = a.drop(start + 1).indexOf(a[start]) + start + 1
		val rev = mutableListOf<Int>()
		for (i in start + 1 until repeat) {
			insertions.add(x + (repeat - start) + (i - start) to a[i])
			rev.add(a[i])
		}
		tandems.add((repeat - start) * 2)
		x += (repeat - start) * 2
		rev.reverse()
		for (i in rev.indices) {
			a[start + 2 + i] = rev[i]
		}
		start += 2
	}
	println(insertions.size)
	for (insertion in insertions) {
		println("${insertion.first} ${insertion.second}")
	}
	println(tandems.size)
	println(tandems.joinToString(" "))
}

fun main() = repeat(readInt()) { solve() }

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

Compiled from "b.kt"
public final class codeforces.round773.BKt {
  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: pop
       4: invokestatic  #14                 // Method readInts:()Ljava/util/List;
       7: checkcast     #16                 // class java/util/Collection
      10: invokestatic  #22                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
      13: astore_0
      14: aload_0
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_2
      19: astore        4
      21: new           #24                 // class java/util/LinkedHashMap
      24: dup
      25: invokespecial #27                 // Method java/util/LinkedHashMap."<init>":()V
      28: checkcast     #29                 // class java/util/Map
      31: astore        5
      33: iconst_0
      34: istore        6
      36: iconst_0
      37: istore        7
      39: aload         4
      41: arraylength
      42: istore        8
      44: iload         7
      46: iload         8
      48: if_icmpge     154
      51: aload         4
      53: iload         7
      55: iaload
      56: istore        9
      58: iload         9
      60: istore        10
      62: iconst_0
      63: istore        11
      65: iload         10
      67: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      70: astore        12
      72: aload         5
      74: astore        13
      76: iconst_0
      77: istore        14
      79: aload         13
      81: aload         12
      83: invokeinterface #39,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      88: astore        15
      90: aload         15
      92: ifnonnull     127
      95: iconst_0
      96: istore        16
      98: new           #41                 // class java/util/ArrayList
     101: dup
     102: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
     105: checkcast     #44                 // class java/util/List
     108: astore        16
     110: aload         13
     112: aload         12
     114: aload         16
     116: invokeinterface #48,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     121: pop
     122: aload         16
     124: goto          129
     127: aload         15
     129: nop
     130: checkcast     #44                 // class java/util/List
     133: astore        10
     135: aload         10
     137: iload         9
     139: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     142: invokeinterface #52,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     147: pop
     148: iinc          7, 1
     151: goto          44
     154: aload         5
     156: nop
     157: astore_1
     158: aload_1
     159: invokeinterface #56,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     164: checkcast     #58                 // class java/lang/Iterable
     167: astore_2
     168: iconst_0
     169: istore_3
     170: aload_2
     171: instanceof    #16                 // class java/util/Collection
     174: ifeq          193
     177: aload_2
     178: checkcast     #16                 // class java/util/Collection
     181: invokeinterface #62,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     186: ifeq          193
     189: iconst_0
     190: goto          255
     193: aload_2
     194: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     199: astore        4
     201: aload         4
     203: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     208: ifeq          254
     211: aload         4
     213: invokeinterface #75,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     218: astore        5
     220: aload         5
     222: checkcast     #44                 // class java/util/List
     225: astore        6
     227: iconst_0
     228: istore        7
     230: aload         6
     232: invokeinterface #78,  1           // InterfaceMethod java/util/List.size:()I
     237: iconst_2
     238: irem
     239: ifeq          246
     242: iconst_1
     243: goto          247
     246: iconst_0
     247: ifeq          201
     250: iconst_1
     251: goto          255
     254: iconst_0
     255: ifeq          268
     258: iconst_m1
     259: istore_2
     260: getstatic     #84                 // Field java/lang/System.out:Ljava/io/PrintStream;
     263: iload_2
     264: invokevirtual #90                 // Method java/io/PrintStream.println:(I)V
     267: return
     268: iconst_0
     269: istore_2
     270: new           #41                 // class java/util/ArrayList
     273: dup
     274: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
     277: checkcast     #44                 // class java/util/List
     280: astore_3
     281: new           #41                 // class java/util/ArrayList
     284: dup
     285: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
     288: checkcast     #44                 // class java/util/List
     291: astore        4
     293: iconst_0
     294: istore        5
     296: iload_2
     297: aload_0
     298: arraylength
     299: if_icmpge     493
     302: aload_0
     303: iload_2
     304: iconst_1
     305: iadd
     306: invokestatic  #96                 // Method kotlin/collections/ArraysKt.drop:([II)Ljava/util/List;
     309: aload_0
     310: iload_2
     311: iaload
     312: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     315: invokeinterface #100,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     320: iload_2
     321: iadd
     322: iconst_1
     323: iadd
     324: istore        6
     326: new           #41                 // class java/util/ArrayList
     329: dup
     330: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
     333: checkcast     #44                 // class java/util/List
     336: astore        7
     338: iload_2
     339: iconst_1
     340: iadd
     341: istore        8
     343: iload         8
     345: iload         6
     347: if_icmpge     403
     350: aload_3
     351: iload         5
     353: iload         6
     355: iload_2
     356: isub
     357: iadd
     358: iload         8
     360: iload_2
     361: isub
     362: iadd
     363: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     366: aload_0
     367: iload         8
     369: iaload
     370: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     373: invokestatic  #106                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     376: invokeinterface #52,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     381: pop
     382: aload         7
     384: aload_0
     385: iload         8
     387: iaload
     388: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     391: invokeinterface #52,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     396: pop
     397: iinc          8, 1
     400: goto          343
     403: aload         4
     405: iload         6
     407: iload_2
     408: isub
     409: iconst_2
     410: imul
     411: invokestatic  #35                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     414: invokeinterface #52,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     419: pop
     420: iload         5
     422: iload         6
     424: iload_2
     425: isub
     426: iconst_2
     427: imul
     428: iadd
     429: istore        5
     431: aload         7
     433: invokestatic  #110                // Method kotlin/collections/CollectionsKt.reverse:(Ljava/util/List;)V
     436: iconst_0
     437: istore        8
     439: aload         7
     441: checkcast     #16                 // class java/util/Collection
     444: invokeinterface #111,  1          // InterfaceMethod java/util/Collection.size:()I
     449: istore        9
     451: iload         8
     453: iload         9
     455: if_icmpge     487
     458: aload_0
     459: iload_2
     460: iconst_2
     461: iadd
     462: iload         8
     464: iadd
     465: aload         7
     467: iload         8
     469: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     474: checkcast     #116                // class java/lang/Number
     477: invokevirtual #119                // Method java/lang/Number.intValue:()I
     480: iastore
     481: iinc          8, 1
     484: goto          451
     487: iinc          2, 2
     490: goto          296
     493: aload_3
     494: invokeinterface #78,  1           // InterfaceMethod java/util/List.size:()I
     499: istore        6
     501: getstatic     #84                 // Field java/lang/System.out:Ljava/io/PrintStream;
     504: iload         6
     506: invokevirtual #90                 // Method java/io/PrintStream.println:(I)V
     509: aload_3
     510: invokeinterface #120,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     515: astore        6
     517: aload         6
     519: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     524: ifeq          592
     527: aload         6
     529: invokeinterface #75,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     534: checkcast     #122                // class kotlin/Pair
     537: astore        7
     539: new           #124                // class java/lang/StringBuilder
     542: dup
     543: invokespecial #125                // Method java/lang/StringBuilder."<init>":()V
     546: aload         7
     548: invokevirtual #128                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     551: checkcast     #116                // class java/lang/Number
     554: invokevirtual #119                // Method java/lang/Number.intValue:()I
     557: invokevirtual #132                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     560: bipush        32
     562: invokevirtual #135                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     565: aload         7
     567: invokevirtual #138                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     570: checkcast     #116                // class java/lang/Number
     573: invokevirtual #119                // Method java/lang/Number.intValue:()I
     576: invokevirtual #132                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     579: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     582: getstatic     #84                 // Field java/lang/System.out:Ljava/io/PrintStream;
     585: swap
     586: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     589: goto          517
     592: aload         4
     594: invokeinterface #78,  1           // InterfaceMethod java/util/List.size:()I
     599: istore        6
     601: getstatic     #84                 // Field java/lang/System.out:Ljava/io/PrintStream;
     604: iload         6
     606: invokevirtual #90                 // Method java/io/PrintStream.println:(I)V
     609: aload         4
     611: checkcast     #58                 // class java/lang/Iterable
     614: ldc           #147                // String
     616: checkcast     #149                // class java/lang/CharSequence
     619: aconst_null
     620: aconst_null
     621: iconst_0
     622: aconst_null
     623: aconst_null
     624: bipush        62
     626: aconst_null
     627: invokestatic  #153                // 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;
     630: getstatic     #84                 // Field java/lang/System.out:Ljava/io/PrintStream;
     633: swap
     634: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     637: return

  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     24
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: invokestatic  #193                // Method solve:()V
      18: iinc          1, 1
      21: goto          6
      24: return

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

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

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

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


package codeforces.round576

fun main() {
	val (n, rectNum) = readInts()
	val rectangles = Array(rectNum) { readInts() }
	val xSet = mutableSetOf(0, n)
	val ySet = mutableSetOf(0, n)
	for ((x1, y1, x2, y2) in rectangles) {
		xSet.add(x1 - 1)
		xSet.add(x2)
		ySet.add(y1 - 1)
		ySet.add(y2)
	}
	val xs = xSet.sorted()
	val ys = ySet.sorted()
	val m = xs.size + ys.size + 2
	val c = Array(m) { IntArray(m) }
	for (i in 0 until xs.size - 1) {
		c[m - 2][i] = xs[i + 1] - xs[i]
	}
	for (j in 0 until ys.size - 1) {
		c[xs.size + j][m - 1] = ys[j + 1] - ys[j]
	}
	for ((x1, y1, x2, y2) in rectangles) {
		for (i in xs.indices) {
			if ((xs[i] < x1 - 1) || (xs[i] >= x2)) continue
			for (j in ys.indices) {
				if ((ys[j] < y1 - 1) || (ys[j] >= y2)) continue
				c[i][xs.size + j] = minOf(xs[i + 1] - xs[i], ys[j + 1] - ys[j])
			}
		}
	}
	println(edmonsKarp(c, m - 2, m - 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 = Integer.MAX_VALUE / 2
		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
}

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

Compiled from "e.kt"
public final class codeforces.round576.EKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: iconst_0
      33: istore        4
      35: iload_2
      36: anewarray     #12                 // class java/util/List
      39: astore        5
      41: iload         4
      43: iload_2
      44: if_icmpge     65
      47: iload         4
      49: istore        6
      51: aload         5
      53: iload         6
      55: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      58: aastore
      59: iinc          4, 1
      62: goto          41
      65: aload         5
      67: astore_3
      68: iconst_2
      69: anewarray     #24                 // class java/lang/Integer
      72: astore        5
      74: aload         5
      76: iconst_0
      77: iconst_0
      78: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      81: aastore
      82: aload         5
      84: iconst_1
      85: iload_1
      86: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: aastore
      90: aload         5
      92: invokestatic  #34                 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      95: astore        4
      97: iconst_2
      98: anewarray     #24                 // class java/lang/Integer
     101: astore        6
     103: aload         6
     105: iconst_0
     106: iconst_0
     107: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     110: aastore
     111: aload         6
     113: iconst_1
     114: iload_1
     115: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     118: aastore
     119: aload         6
     121: invokestatic  #34                 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
     124: astore        5
     126: iconst_0
     127: istore        6
     129: aload_3
     130: arraylength
     131: istore        7
     133: iload         6
     135: iload         7
     137: if_icmpge     272
     140: aload_3
     141: iload         6
     143: aaload
     144: astore        8
     146: aload         8
     148: iconst_0
     149: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     154: checkcast     #18                 // class java/lang/Number
     157: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     160: istore        9
     162: aload         8
     164: iconst_1
     165: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     170: checkcast     #18                 // class java/lang/Number
     173: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     176: istore        10
     178: aload         8
     180: iconst_2
     181: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     186: checkcast     #18                 // class java/lang/Number
     189: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     192: istore        11
     194: aload         8
     196: iconst_3
     197: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     202: checkcast     #18                 // class java/lang/Number
     205: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     208: istore        12
     210: aload         4
     212: iload         9
     214: iconst_1
     215: isub
     216: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     219: invokeinterface #40,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     224: pop
     225: aload         4
     227: iload         11
     229: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: invokeinterface #40,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     237: pop
     238: aload         5
     240: iload         10
     242: iconst_1
     243: isub
     244: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     247: invokeinterface #40,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     252: pop
     253: aload         5
     255: iload         12
     257: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     260: invokeinterface #40,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     265: pop
     266: iinc          6, 1
     269: goto          133
     272: aload         4
     274: checkcast     #42                 // class java/lang/Iterable
     277: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     280: astore        6
     282: aload         5
     284: checkcast     #42                 // class java/lang/Iterable
     287: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     290: astore        7
     292: aload         6
     294: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     299: aload         7
     301: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     306: iadd
     307: iconst_2
     308: iadd
     309: istore        8
     311: iconst_0
     312: istore        10
     314: iload         8
     316: anewarray     #53                 // class "[I"
     319: astore        11
     321: iload         10
     323: iload         8
     325: if_icmpge     347
     328: iload         10
     330: istore        12
     332: aload         11
     334: iload         12
     336: iload         8
     338: newarray       int
     340: aastore
     341: iinc          10, 1
     344: goto          321
     347: aload         11
     349: astore        9
     351: iconst_0
     352: istore        10
     354: aload         6
     356: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     361: iconst_1
     362: isub
     363: istore        11
     365: iload         10
     367: iload         11
     369: if_icmpge     421
     372: aload         9
     374: iload         8
     376: iconst_2
     377: isub
     378: aaload
     379: iload         10
     381: aload         6
     383: iload         10
     385: iconst_1
     386: iadd
     387: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     392: checkcast     #18                 // class java/lang/Number
     395: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     398: aload         6
     400: iload         10
     402: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     407: checkcast     #18                 // class java/lang/Number
     410: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     413: isub
     414: iastore
     415: iinc          10, 1
     418: goto          365
     421: iconst_0
     422: istore        10
     424: aload         7
     426: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     431: iconst_1
     432: isub
     433: istore        11
     435: iload         10
     437: iload         11
     439: if_icmpge     499
     442: aload         9
     444: aload         6
     446: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     451: iload         10
     453: iadd
     454: aaload
     455: iload         8
     457: iconst_1
     458: isub
     459: aload         7
     461: iload         10
     463: iconst_1
     464: iadd
     465: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     470: checkcast     #18                 // class java/lang/Number
     473: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     476: aload         7
     478: iload         10
     480: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     485: checkcast     #18                 // class java/lang/Number
     488: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     491: isub
     492: iastore
     493: iinc          10, 1
     496: goto          435
     499: iconst_0
     500: istore        10
     502: aload_3
     503: arraylength
     504: istore        11
     506: iload         10
     508: iload         11
     510: if_icmpge     820
     513: aload_3
     514: iload         10
     516: aaload
     517: astore        12
     519: aload         12
     521: iconst_0
     522: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     527: checkcast     #18                 // class java/lang/Number
     530: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     533: istore        13
     535: aload         12
     537: iconst_1
     538: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     543: checkcast     #18                 // class java/lang/Number
     546: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     549: istore        14
     551: aload         12
     553: iconst_2
     554: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     559: checkcast     #18                 // class java/lang/Number
     562: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     565: istore        15
     567: aload         12
     569: iconst_3
     570: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     575: checkcast     #18                 // class java/lang/Number
     578: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     581: istore        16
     583: iconst_0
     584: istore        17
     586: aload         6
     588: checkcast     #55                 // class java/util/Collection
     591: invokeinterface #56,  1           // InterfaceMethod java/util/Collection.size:()I
     596: istore        18
     598: iload         17
     600: iload         18
     602: if_icmpge     814
     605: aload         6
     607: iload         17
     609: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     614: checkcast     #18                 // class java/lang/Number
     617: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     620: iload         13
     622: iconst_1
     623: isub
     624: if_icmplt     808
     627: aload         6
     629: iload         17
     631: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     636: checkcast     #18                 // class java/lang/Number
     639: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     642: iload         15
     644: if_icmplt     650
     647: goto          808
     650: iconst_0
     651: istore        19
     653: aload         7
     655: checkcast     #55                 // class java/util/Collection
     658: invokeinterface #56,  1           // InterfaceMethod java/util/Collection.size:()I
     663: istore        20
     665: iload         19
     667: iload         20
     669: if_icmpge     808
     672: aload         7
     674: iload         19
     676: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     681: checkcast     #18                 // class java/lang/Number
     684: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     687: iload         14
     689: iconst_1
     690: isub
     691: if_icmplt     802
     694: aload         7
     696: iload         19
     698: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     703: checkcast     #18                 // class java/lang/Number
     706: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     709: iload         16
     711: if_icmplt     717
     714: goto          802
     717: aload         9
     719: iload         17
     721: aaload
     722: aload         6
     724: invokeinterface #51,  1           // InterfaceMethod java/util/List.size:()I
     729: iload         19
     731: iadd
     732: aload         6
     734: iload         17
     736: iconst_1
     737: iadd
     738: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     743: checkcast     #18                 // class java/lang/Number
     746: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     749: aload         6
     751: iload         17
     753: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     758: checkcast     #18                 // class java/lang/Number
     761: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     764: isub
     765: aload         7
     767: iload         19
     769: iconst_1
     770: iadd
     771: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     776: checkcast     #18                 // class java/lang/Number
     779: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     782: aload         7
     784: iload         19
     786: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     791: checkcast     #18                 // class java/lang/Number
     794: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     797: isub
     798: invokestatic  #62                 // Method java/lang/Math.min:(II)I
     801: iastore
     802: iinc          19, 1
     805: goto          665
     808: iinc          17, 1
     811: goto          598
     814: iinc          10, 1
     817: goto          506
     820: aload         9
     822: iload         8
     824: iconst_2
     825: isub
     826: iload         8
     828: iconst_1
     829: isub
     830: invokestatic  #66                 // Method edmonsKarp:([[III)I
     833: istore        10
     835: getstatic     #72                 // Field java/lang/System.out:Ljava/io/PrintStream;
     838: iload         10
     840: invokevirtual #78                 // Method java/io/PrintStream.println:(I)V
     843: return

  public static final int edmonsKarp(int[][], int, int);
    Code:
       0: aload_0
       1: ldc           #102                // String c
       3: invokestatic  #108                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #110                // class "[Ljava/lang/Object;"
      10: arraylength
      11: istore_3
      12: iconst_0
      13: istore        5
      15: iload_3
      16: anewarray     #53                 // 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  #116                // 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           #117                // int 1073741823
     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  #62                 // 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

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

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


package codeforces.round576

fun main() {
	val n = readInt()
	val f = Array(n) { readLn().map { if (it == '#') 1 else 0 } }
	val cum = Array(n + 1) { IntArray(n + 1) }
	for (i in 0 until n) {
		for (j in 0 until n) {
			cum[i + 1][j + 1] = cum[i][j + 1] + cum[i + 1][j] - cum[i][j] + f[i][j]
		}
	}
	val dp = Array(n + 1) { Array(n + 1) { Array(n + 1) { IntArray(n + 1) }}}
	for (i1 in n - 1 downTo 0) {
		for (i2 in i1 + 1..n) {
			for (j1 in n - 1 downTo 0) {
				for (j2 in j1 + 1..n) {
					if (sum(cum, i1, j1, i2, j2) == 0) continue
					var res = maxOf(i2 - i1, j2 - j1)
					for (i in i1 until i2) {
						if (sum(cum, i, j1, i + 1, j2) != 0) continue
						res = minOf(res, dp[i1][j1][i][j2] + dp[i + 1][j1][i2][j2])
					}
					for (j in j1 until j2) {
						if (sum(cum, i1, j, i2, j + 1) != 0) continue
						res = minOf(res, dp[i1][j1][i2][j] + dp[i1][j + 1][i2][j2])
					}
					dp[i1][j1][i2][j2] = res
				}
			}
		}
	}
	println(dp[0][0][n][n])
}

private fun sum(cum: Array<IntArray>, i1: Int, j1: Int, i2: Int, j2: Int) =
		cum[i2][j2] - cum[i1][j2] - cum[i2][j1] + cum[i1][j1]

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()

Compiled from "d.kt"
public final class codeforces.round576.DKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_2
       6: iload_0
       7: anewarray     #12                 // class java/util/List
      10: astore_3
      11: iload_2
      12: iload_0
      13: if_icmpge     151
      16: iload_2
      17: istore        4
      19: aload_3
      20: iload         4
      22: invokestatic  #16                 // Method readLn:()Ljava/lang/String;
      25: checkcast     #18                 // class java/lang/CharSequence
      28: astore        5
      30: istore        17
      32: astore        16
      34: iconst_0
      35: istore        6
      37: aload         5
      39: astore        7
      41: new           #20                 // class java/util/ArrayList
      44: dup
      45: aload         5
      47: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      52: invokespecial #27                 // Method java/util/ArrayList."<init>":(I)V
      55: checkcast     #29                 // class java/util/Collection
      58: astore        8
      60: iconst_0
      61: istore        9
      63: iconst_0
      64: istore        10
      66: iload         10
      68: aload         7
      70: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      75: if_icmpge     130
      78: aload         7
      80: iload         10
      82: invokeinterface #33,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      87: istore        11
      89: aload         8
      91: iload         11
      93: istore        12
      95: astore        18
      97: iconst_0
      98: istore        13
     100: iload         12
     102: bipush        35
     104: if_icmpne     111
     107: iconst_1
     108: goto          112
     111: iconst_0
     112: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: aload         18
     117: swap
     118: invokeinterface #43,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     123: pop
     124: iinc          10, 1
     127: goto          66
     130: aload         8
     132: checkcast     #12                 // class java/util/List
     135: nop
     136: astore        18
     138: aload         16
     140: iload         17
     142: aload         18
     144: aastore
     145: iinc          2, 1
     148: goto          11
     151: aload_3
     152: astore_1
     153: iconst_0
     154: istore_3
     155: iload_0
     156: iconst_1
     157: iadd
     158: istore        4
     160: iload         4
     162: anewarray     #45                 // class "[I"
     165: astore        5
     167: iload_3
     168: iload         4
     170: if_icmpge     192
     173: iload_3
     174: istore        6
     176: aload         5
     178: iload         6
     180: iload_0
     181: iconst_1
     182: iadd
     183: newarray       int
     185: aastore
     186: iinc          3, 1
     189: goto          167
     192: aload         5
     194: astore_2
     195: iconst_0
     196: istore_3
     197: iload_3
     198: iload_0
     199: if_icmpge     274
     202: iconst_0
     203: istore        4
     205: iload         4
     207: iload_0
     208: if_icmpge     268
     211: aload_2
     212: iload_3
     213: iconst_1
     214: iadd
     215: aaload
     216: iload         4
     218: iconst_1
     219: iadd
     220: aload_2
     221: iload_3
     222: aaload
     223: iload         4
     225: iconst_1
     226: iadd
     227: iaload
     228: aload_2
     229: iload_3
     230: iconst_1
     231: iadd
     232: aaload
     233: iload         4
     235: iaload
     236: iadd
     237: aload_2
     238: iload_3
     239: aaload
     240: iload         4
     242: iaload
     243: isub
     244: aload_1
     245: iload_3
     246: aaload
     247: iload         4
     249: invokeinterface #49,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #51                 // class java/lang/Number
     257: invokevirtual #54                 // Method java/lang/Number.intValue:()I
     260: iadd
     261: iastore
     262: iinc          4, 1
     265: goto          205
     268: iinc          3, 1
     271: goto          197
     274: iconst_0
     275: istore        4
     277: iload_0
     278: iconst_1
     279: iadd
     280: istore        5
     282: iload         5
     284: anewarray     #56                 // class "[[[I"
     287: astore        6
     289: iload         4
     291: iload         5
     293: if_icmpge     410
     296: iload         4
     298: istore        7
     300: aload         6
     302: iload         7
     304: iconst_0
     305: istore        8
     307: iload_0
     308: iconst_1
     309: iadd
     310: istore        9
     312: iload         9
     314: anewarray     #58                 // class "[[I"
     317: astore        10
     319: istore        17
     321: astore        16
     323: iload         8
     325: iload         9
     327: if_icmpge     397
     330: iload         8
     332: istore        11
     334: aload         10
     336: iload         11
     338: iconst_0
     339: istore        12
     341: iload_0
     342: iconst_1
     343: iadd
     344: istore        13
     346: iload         13
     348: anewarray     #45                 // class "[I"
     351: astore        14
     353: istore        19
     355: astore        18
     357: iload         12
     359: iload         13
     361: if_icmpge     384
     364: iload         12
     366: istore        15
     368: aload         14
     370: iload         15
     372: iload_0
     373: iconst_1
     374: iadd
     375: newarray       int
     377: aastore
     378: iinc          12, 1
     381: goto          357
     384: aload         18
     386: iload         19
     388: aload         14
     390: aastore
     391: iinc          8, 1
     394: goto          323
     397: aload         16
     399: iload         17
     401: aload         10
     403: aastore
     404: iinc          4, 1
     407: goto          289
     410: aload         6
     412: astore_3
     413: iload_0
     414: iconst_1
     415: isub
     416: istore        4
     418: iconst_m1
     419: iload         4
     421: if_icmpge     680
     424: iload         4
     426: iconst_1
     427: iadd
     428: istore        5
     430: iload         5
     432: iload_0
     433: if_icmpgt     674
     436: iload_0
     437: iconst_1
     438: isub
     439: istore        6
     441: iconst_m1
     442: iload         6
     444: if_icmpge     662
     447: iload         6
     449: iconst_1
     450: iadd
     451: istore        7
     453: iload         7
     455: iload_0
     456: if_icmpgt     656
     459: aload_2
     460: iload         4
     462: iload         6
     464: iload         5
     466: iload         7
     468: invokestatic  #62                 // Method sum:([[IIIII)I
     471: ifeq          644
     474: iload         5
     476: iload         4
     478: isub
     479: iload         7
     481: iload         6
     483: isub
     484: invokestatic  #68                 // Method java/lang/Math.max:(II)I
     487: istore        8
     489: iload         4
     491: istore        9
     493: iload         9
     495: iload         5
     497: if_icmpge     559
     500: aload_2
     501: iload         9
     503: iload         6
     505: iload         9
     507: iconst_1
     508: iadd
     509: iload         7
     511: invokestatic  #62                 // Method sum:([[IIIII)I
     514: ifne          553
     517: iload         8
     519: aload_3
     520: iload         4
     522: aaload
     523: iload         6
     525: aaload
     526: iload         9
     528: aaload
     529: iload         7
     531: iaload
     532: aload_3
     533: iload         9
     535: iconst_1
     536: iadd
     537: aaload
     538: iload         6
     540: aaload
     541: iload         5
     543: aaload
     544: iload         7
     546: iaload
     547: iadd
     548: invokestatic  #71                 // Method java/lang/Math.min:(II)I
     551: istore        8
     553: iinc          9, 1
     556: goto          493
     559: iload         6
     561: istore        9
     563: iload         9
     565: iload         7
     567: if_icmpge     629
     570: aload_2
     571: iload         4
     573: iload         9
     575: iload         5
     577: iload         9
     579: iconst_1
     580: iadd
     581: invokestatic  #62                 // Method sum:([[IIIII)I
     584: ifne          623
     587: iload         8
     589: aload_3
     590: iload         4
     592: aaload
     593: iload         6
     595: aaload
     596: iload         5
     598: aaload
     599: iload         9
     601: iaload
     602: aload_3
     603: iload         4
     605: aaload
     606: iload         9
     608: iconst_1
     609: iadd
     610: aaload
     611: iload         5
     613: aaload
     614: iload         7
     616: iaload
     617: iadd
     618: invokestatic  #71                 // Method java/lang/Math.min:(II)I
     621: istore        8
     623: iinc          9, 1
     626: goto          563
     629: aload_3
     630: iload         4
     632: aaload
     633: iload         6
     635: aaload
     636: iload         5
     638: aaload
     639: iload         7
     641: iload         8
     643: iastore
     644: iload         7
     646: iload_0
     647: if_icmpeq     656
     650: iinc          7, 1
     653: goto          459
     656: iinc          6, -1
     659: goto          441
     662: iload         5
     664: iload_0
     665: if_icmpeq     674
     668: iinc          5, 1
     671: goto          436
     674: iinc          4, -1
     677: goto          418
     680: aload_3
     681: iconst_0
     682: aaload
     683: iconst_0
     684: aaload
     685: iload_0
     686: aaload
     687: iload_0
     688: iaload
     689: istore        4
     691: getstatic     #77                 // Field java/lang/System.out:Ljava/io/PrintStream;
     694: iload         4
     696: invokevirtual #82                 // Method java/io/PrintStream.println:(I)V
     699: return

  private static final int sum(int[][], int, int, int, int);
    Code:
       0: aload_0
       1: iload_3
       2: aaload
       3: iload         4
       5: iaload
       6: aload_0
       7: iload_1
       8: aaload
       9: iload         4
      11: iaload
      12: isub
      13: aload_0
      14: iload_3
      15: aaload
      16: iload_2
      17: iaload
      18: isub
      19: aload_0
      20: iload_1
      21: aaload
      22: iload_2
      23: iaload
      24: iadd
      25: ireturn

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

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

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


package codeforces.round631

private fun solve(): String {
	val (h, g) = readInts()
	val a = (listOf(0) + readInts()).toIntArray()
	val bottomLevel = 1 shl (h - 1)
	tailrec fun siftDown(i: Int, act: Boolean): Int {
		val j = if (i >= bottomLevel) 0 else if (a[2 * i] >= a[2 * i + 1]) 2 * i else 2 * i + 1
		if (act) a[i] = a[j]
		return if (a[j] == 0) i else siftDown(j, act)
	}
	val toLeave = 1 shl g
	val ans = mutableListOf<Int>()
	for (i in 1 until toLeave) {
		while (siftDown(i, false) >= toLeave) {
			ans.add(i)
			siftDown(i, true)
		}
	}
	return "${a.fold(0L, Long::plus)}\n${ans.joinToString(" ")}"
}

fun main() = println(List(readInt()) { solve() }.joinToString("\n"))

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 codeforces.round631.CKt {
  private static final java.lang.String solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: iconst_0
      33: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      36: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      39: checkcast     #36                 // class java/util/Collection
      42: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      45: checkcast     #38                 // class java/lang/Iterable
      48: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      51: checkcast     #36                 // class java/util/Collection
      54: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
      57: astore_3
      58: iconst_1
      59: iload_1
      60: iconst_1
      61: isub
      62: ishl
      63: istore        4
      65: iconst_1
      66: iload_2
      67: ishl
      68: istore        5
      70: new           #48                 // class java/util/ArrayList
      73: dup
      74: invokespecial #52                 // Method java/util/ArrayList."<init>":()V
      77: checkcast     #12                 // class java/util/List
      80: astore        6
      82: iconst_1
      83: istore        7
      85: iload         7
      87: iload         5
      89: if_icmpge     138
      92: iload         4
      94: aload_3
      95: iload         7
      97: iconst_0
      98: invokestatic  #56                 // Method solve$siftDown:(I[IIZ)I
     101: iload         5
     103: if_icmplt     132
     106: aload         6
     108: iload         7
     110: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     113: invokeinterface #60,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     118: pop
     119: iload         4
     121: aload_3
     122: iload         7
     124: iconst_1
     125: invokestatic  #56                 // Method solve$siftDown:(I[IIZ)I
     128: pop
     129: goto          92
     132: iinc          7, 1
     135: goto          85
     138: new           #62                 // class java/lang/StringBuilder
     141: dup
     142: invokespecial #63                 // Method java/lang/StringBuilder."<init>":()V
     145: aload_3
     146: astore        7
     148: lconst_0
     149: lstore        8
     151: astore        20
     153: iconst_0
     154: istore        10
     156: lload         8
     158: lstore        11
     160: iconst_0
     161: istore        13
     163: aload         7
     165: arraylength
     166: istore        14
     168: iload         13
     170: iload         14
     172: if_icmpge     207
     175: aload         7
     177: iload         13
     179: iaload
     180: istore        15
     182: lload         11
     184: iload         15
     186: istore        16
     188: lstore        17
     190: iconst_0
     191: istore        19
     193: lload         17
     195: iload         16
     197: i2l
     198: ladd
     199: lstore        11
     201: iinc          13, 1
     204: goto          168
     207: lload         11
     209: lstore        21
     211: aload         20
     213: lload         21
     215: invokevirtual #67                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     218: bipush        10
     220: invokevirtual #70                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     223: aload         6
     225: checkcast     #38                 // class java/lang/Iterable
     228: ldc           #72                 // String
     230: checkcast     #74                 // class java/lang/CharSequence
     233: aconst_null
     234: aconst_null
     235: iconst_0
     236: aconst_null
     237: aconst_null
     238: bipush        62
     240: aconst_null
     241: invokestatic  #78                 // 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;
     244: invokevirtual #81                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     247: invokevirtual #84                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     250: areturn

  public static final void main();
    Code:
       0: invokestatic  #108                // Method readInt:()I
       3: istore_0
       4: new           #48                 // class java/util/ArrayList
       7: dup
       8: iload_0
       9: invokespecial #111                // Method java/util/ArrayList."<init>":(I)V
      12: astore_1
      13: iconst_0
      14: istore_2
      15: iload_2
      16: iload_0
      17: if_icmpge     47
      20: iload_2
      21: istore_3
      22: aload_1
      23: iload_3
      24: istore        4
      26: astore        6
      28: iconst_0
      29: istore        5
      31: invokestatic  #113                // Method solve:()Ljava/lang/String;
      34: aload         6
      36: swap
      37: invokevirtual #114                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      40: pop
      41: iinc          2, 1
      44: goto          15
      47: aload_1
      48: checkcast     #12                 // class java/util/List
      51: checkcast     #38                 // class java/lang/Iterable
      54: ldc           #116                // String \n
      56: checkcast     #74                 // class java/lang/CharSequence
      59: aconst_null
      60: aconst_null
      61: iconst_0
      62: aconst_null
      63: aconst_null
      64: bipush        62
      66: aconst_null
      67: invokestatic  #78                 // 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;
      70: getstatic     #122                // Field java/lang/System.out:Ljava/io/PrintStream;
      73: swap
      74: invokevirtual #128                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      77: return

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

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

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

  private static final int solve$siftDown(int, int[], int, boolean);
    Code:
       0: iload_2
       1: iload_0
       2: if_icmplt     9
       5: iconst_0
       6: goto          35
       9: aload_1
      10: iconst_2
      11: iload_2
      12: imul
      13: iaload
      14: aload_1
      15: iconst_2
      16: iload_2
      17: imul
      18: iconst_1
      19: iadd
      20: iaload
      21: if_icmplt     30
      24: iconst_2
      25: iload_2
      26: imul
      27: goto          35
      30: iconst_2
      31: iload_2
      32: imul
      33: iconst_1
      34: iadd
      35: istore        4
      37: iload_3
      38: ifeq          48
      41: aload_1
      42: iload_2
      43: aload_1
      44: iload         4
      46: iaload
      47: iastore
      48: aload_1
      49: iload         4
      51: iaload
      52: ifne          59
      55: iload_2
      56: goto          71
      59: iload_3
      60: istore        5
      62: iload         4
      64: istore_2
      65: iload         5
      67: istore_3
      68: goto          0
      71: ireturn
}


package codeforces.kotlinheroes1

fun main() {
    val (n, m, canIncrease) = readInts()
    val a = readInts().sorted()
    val acc = mutableListOf(0L)
    for (i in 0 until n) { acc.add(acc[i] + a[i]) }
    var ans = a.fold(0L, Long::plus)
    for (left in 0..n - m) {
        var low = a[left]
        var high = a[left + (m - 1) / 2] + 1
        while (low + 1 < high) {
            val mid = (low + high) / 2
            val index = a.binarySearch(mid, left, m)
            val increases = (index - left) * 1L * mid - (acc[index] - acc[left])
            if (increases <= canIncrease) {
                low = mid
            } else {
                high = mid
            }
        }
        val index = a.binarySearch(low, left, m)
        val ops = (index - left) * 1L * low - (acc[index] - acc[left]) +
                (acc[left + m] - acc[index]) - (left + m - index) * 1L * low
        ans = minOf(ans, ops)
    }
    println(ans)
}

private fun List<Int>.binarySearch(value: Int, from: Int, length: Int): Int {
    val binarySearch = this.binarySearch(value, from, from + length)
    return if (binarySearch >= 0) binarySearch else -1 - binarySearch
}

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

Compiled from "f.kt"
public final class codeforces.kotlinheroes1.FKt {
  public static final void main();
    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: 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 #22                 // Method java/lang/Number.intValue:()I
      45: istore_3
      46: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      49: checkcast     #24                 // class java/lang/Iterable
      52: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      55: astore        4
      57: iconst_1
      58: anewarray     #32                 // class java/lang/Long
      61: astore        6
      63: aload         6
      65: iconst_0
      66: lconst_0
      67: invokestatic  #36                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      70: aastore
      71: aload         6
      73: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      76: astore        5
      78: iconst_0
      79: istore        6
      81: iload         6
      83: iload_1
      84: if_icmpge     135
      87: aload         5
      89: aload         5
      91: iload         6
      93: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      98: checkcast     #18                 // class java/lang/Number
     101: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     104: aload         4
     106: iload         6
     108: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     113: checkcast     #18                 // class java/lang/Number
     116: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     119: ladd
     120: invokestatic  #36                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     123: invokeinterface #48,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     128: pop
     129: iinc          6, 1
     132: goto          81
     135: aload         4
     137: checkcast     #24                 // class java/lang/Iterable
     140: astore        8
     142: lconst_0
     143: lstore        9
     145: iconst_0
     146: istore        11
     148: lload         9
     150: lstore        12
     152: aload         8
     154: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     159: astore        14
     161: aload         14
     163: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          208
     171: aload         14
     173: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: astore        15
     180: lload         12
     182: aload         15
     184: checkcast     #18                 // class java/lang/Number
     187: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     190: istore        16
     192: lstore        17
     194: iconst_0
     195: istore        19
     197: lload         17
     199: iload         16
     201: i2l
     202: ladd
     203: lstore        12
     205: goto          161
     208: lload         12
     210: lstore        6
     212: iconst_0
     213: istore        8
     215: iload_1
     216: iload_2
     217: isub
     218: istore        9
     220: iload         8
     222: iload         9
     224: if_icmpgt     496
     227: aload         4
     229: iload         8
     231: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     236: checkcast     #18                 // class java/lang/Number
     239: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     242: istore        11
     244: aload         4
     246: iload         8
     248: iload_2
     249: iconst_1
     250: isub
     251: iconst_2
     252: idiv
     253: iadd
     254: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     259: checkcast     #18                 // class java/lang/Number
     262: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     265: iconst_1
     266: iadd
     267: istore        12
     269: iload         11
     271: iconst_1
     272: iadd
     273: iload         12
     275: if_icmpge     367
     278: iload         11
     280: iload         12
     282: iadd
     283: iconst_2
     284: idiv
     285: istore        14
     287: aload         4
     289: iload         14
     291: iload         8
     293: iload_2
     294: invokestatic  #66                 // Method binarySearch:(Ljava/util/List;III)I
     297: istore        15
     299: iload         15
     301: iload         8
     303: isub
     304: i2l
     305: lconst_1
     306: lmul
     307: iload         14
     309: i2l
     310: lmul
     311: aload         5
     313: iload         15
     315: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     320: checkcast     #18                 // class java/lang/Number
     323: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     326: aload         5
     328: iload         8
     330: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     335: checkcast     #18                 // class java/lang/Number
     338: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     341: lsub
     342: lsub
     343: lstore        16
     345: lload         16
     347: iload_3
     348: i2l
     349: lcmp
     350: ifgt          360
     353: iload         14
     355: istore        11
     357: goto          269
     360: iload         14
     362: istore        12
     364: goto          269
     367: aload         4
     369: iload         11
     371: iload         8
     373: iload_2
     374: invokestatic  #66                 // Method binarySearch:(Ljava/util/List;III)I
     377: istore        14
     379: iload         14
     381: iload         8
     383: isub
     384: i2l
     385: lconst_1
     386: lmul
     387: iload         11
     389: i2l
     390: lmul
     391: aload         5
     393: iload         14
     395: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     400: checkcast     #18                 // class java/lang/Number
     403: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     406: aload         5
     408: iload         8
     410: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     415: checkcast     #18                 // class java/lang/Number
     418: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     421: lsub
     422: lsub
     423: aload         5
     425: iload         8
     427: iload_2
     428: iadd
     429: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     434: checkcast     #18                 // class java/lang/Number
     437: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     440: aload         5
     442: iload         14
     444: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     449: checkcast     #18                 // class java/lang/Number
     452: invokevirtual #44                 // Method java/lang/Number.longValue:()J
     455: lsub
     456: ladd
     457: iload         8
     459: iload_2
     460: iadd
     461: iload         14
     463: isub
     464: i2l
     465: lconst_1
     466: lmul
     467: iload         11
     469: i2l
     470: lmul
     471: lsub
     472: lstore        15
     474: lload         6
     476: lload         15
     478: invokestatic  #72                 // Method java/lang/Math.min:(JJ)J
     481: lstore        6
     483: iload         8
     485: iload         9
     487: if_icmpeq     496
     490: iinc          8, 1
     493: goto          227
     496: getstatic     #78                 // Field java/lang/System.out:Ljava/io/PrintStream;
     499: lload         6
     501: invokevirtual #84                 // Method java/io/PrintStream.println:(J)V
     504: return

  private static final int binarySearch(java.util.List<java.lang.Integer>, int, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: iload_2
       3: iload_2
       4: iload_3
       5: iadd
       6: invokestatic  #66                 // Method binarySearch:(Ljava/util/List;III)I
       9: istore        4
      11: iload         4
      13: iflt          21
      16: iload         4
      18: goto          25
      21: iconst_m1
      22: iload         4
      24: isub
      25: ireturn

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

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


package codeforces.kotlinheroes6

import kotlin.math.abs

private fun solve() {
	val (n, xIn, yIn) = readInts()
	val (x, y) = listOf(xIn, yIn).sorted().map { it - 1 }
	val ans = List(n) { m ->
		maxOf(solve(0, m, x), solve(m, n, y))
	}.minOrNull()
	println(ans)
}

private fun solve(from: Int, to: Int, x: Int): Int {
	if (from == to) return 0
	return minOf(dist(x, from), dist(x, to - 1)) + to - from - 1
}

private fun dist(x: Int, y: Int): Int {
	return abs(x - y)
}

fun main() = repeat(readInt()) { solve() }

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

Compiled from "c.kt"
public final class codeforces.kotlinheroes6.CKt {
  private static final void 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: 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 #22                 // Method java/lang/Number.intValue:()I
      45: istore_3
      46: iconst_2
      47: anewarray     #24                 // class java/lang/Integer
      50: astore        5
      52: aload         5
      54: iconst_0
      55: iload_2
      56: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      59: aastore
      60: aload         5
      62: iconst_1
      63: iload_3
      64: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      67: aastore
      68: aload         5
      70: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      73: checkcast     #36                 // class java/lang/Iterable
      76: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      79: checkcast     #36                 // class java/lang/Iterable
      82: astore        5
      84: iconst_0
      85: istore        6
      87: aload         5
      89: astore        7
      91: new           #42                 // class java/util/ArrayList
      94: dup
      95: aload         5
      97: bipush        10
      99: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     102: invokespecial #50                 // Method java/util/ArrayList."<init>":(I)V
     105: checkcast     #52                 // class java/util/Collection
     108: astore        8
     110: iconst_0
     111: istore        9
     113: aload         7
     115: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     120: astore        10
     122: aload         10
     124: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     129: ifeq          177
     132: aload         10
     134: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     139: astore        11
     141: aload         8
     143: aload         11
     145: checkcast     #18                 // class java/lang/Number
     148: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     151: istore        12
     153: astore        14
     155: iconst_0
     156: istore        13
     158: iload         12
     160: iconst_1
     161: isub
     162: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     165: aload         14
     167: swap
     168: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     173: pop
     174: goto          122
     177: aload         8
     179: checkcast     #12                 // class java/util/List
     182: nop
     183: astore        4
     185: aload         4
     187: iconst_0
     188: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     193: checkcast     #18                 // class java/lang/Number
     196: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     199: istore        5
     201: aload         4
     203: iconst_1
     204: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: checkcast     #18                 // class java/lang/Number
     212: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     215: istore        6
     217: new           #42                 // class java/util/ArrayList
     220: dup
     221: iload_1
     222: invokespecial #50                 // Method java/util/ArrayList."<init>":(I)V
     225: astore        8
     227: iconst_0
     228: istore        9
     230: iload         9
     232: iload_1
     233: if_icmpge     287
     236: iload         9
     238: istore        10
     240: aload         8
     242: iload         10
     244: istore        11
     246: astore        14
     248: iconst_0
     249: istore        12
     251: iconst_0
     252: iload         11
     254: iload         5
     256: invokestatic  #73                 // Method solve:(III)I
     259: iload         11
     261: iload_1
     262: iload         6
     264: invokestatic  #73                 // Method solve:(III)I
     267: invokestatic  #79                 // Method java/lang/Math.max:(II)I
     270: nop
     271: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     274: aload         14
     276: swap
     277: invokevirtual #80                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     280: pop
     281: iinc          9, 1
     284: goto          230
     287: aload         8
     289: checkcast     #12                 // class java/util/List
     292: checkcast     #36                 // class java/lang/Iterable
     295: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     298: checkcast     #24                 // class java/lang/Integer
     301: astore        7
     303: getstatic     #90                 // Field java/lang/System.out:Ljava/io/PrintStream;
     306: aload         7
     308: invokevirtual #96                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     311: return

  private static final int solve(int, int, int);
    Code:
       0: iload_0
       1: iload_1
       2: if_icmpne     7
       5: iconst_0
       6: ireturn
       7: iload_2
       8: iload_0
       9: invokestatic  #120                // Method dist:(II)I
      12: iload_2
      13: iload_1
      14: iconst_1
      15: isub
      16: invokestatic  #120                // Method dist:(II)I
      19: invokestatic  #123                // Method java/lang/Math.min:(II)I
      22: iload_1
      23: iadd
      24: iload_0
      25: isub
      26: iconst_1
      27: isub
      28: ireturn

  private static final int dist(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: isub
       3: invokestatic  #129                // Method java/lang/Math.abs:(I)I
       6: ireturn

  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     24
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: invokestatic  #135                // Method solve:()V
      18: iinc          1, 1
      21: goto          6
      24: return

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

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

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