package codeforces.deltix2021summer
import kotlin.math.abs

private fun solve(a: List<Int>, first: Int): Long {
	val aIndices = a.indices.filter { a[it] == 1 }
	val neededIndices = a.indices.filter { it % 2 == 1 - first }
	return aIndices.zip(neededIndices) { x, y -> abs(x - y).toLong() }.sum()
}

private fun solve(): Long {
	readLn()
	val a = readInts().map { it and 1 }
	val n = a.size
	val balance = a.sum() - n / 2
	if (n % 2 == 0) {
		if (balance == 0) return minOf(solve(a, 0), solve(a, 1))
	} else {
		if (balance in 0..1) return solve(a, balance)
	}
	return -1
}

fun main() {
	repeat(readInt()) { println(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.deltix2021summer.BKt {
  private static final long solve(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: checkcast     #9                  // class java/util/Collection
       4: invokestatic  #15                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
       7: checkcast     #17                 // class java/lang/Iterable
      10: astore_3
      11: iconst_0
      12: istore        4
      14: aload_3
      15: astore        5
      17: new           #19                 // class java/util/ArrayList
      20: dup
      21: invokespecial #23                 // Method java/util/ArrayList."<init>":()V
      24: checkcast     #9                  // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        8
      41: aload         8
      43: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          112
      51: aload         8
      53: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        9
      60: aload         9
      62: checkcast     #39                 // class java/lang/Number
      65: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      68: istore        10
      70: iconst_0
      71: istore        11
      73: aload_0
      74: iload         10
      76: invokeinterface #49,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      81: checkcast     #39                 // class java/lang/Number
      84: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      87: iconst_1
      88: if_icmpne     95
      91: iconst_1
      92: goto          96
      95: iconst_0
      96: ifeq          41
      99: aload         6
     101: aload         9
     103: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     108: pop
     109: goto          41
     112: aload         6
     114: checkcast     #45                 // class java/util/List
     117: nop
     118: astore_2
     119: aload_0
     120: checkcast     #9                  // class java/util/Collection
     123: invokestatic  #15                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     126: checkcast     #17                 // class java/lang/Iterable
     129: astore        4
     131: iconst_0
     132: istore        5
     134: aload         4
     136: astore        6
     138: new           #19                 // class java/util/ArrayList
     141: dup
     142: invokespecial #23                 // Method java/util/ArrayList."<init>":()V
     145: checkcast     #9                  // class java/util/Collection
     148: astore        7
     150: iconst_0
     151: istore        8
     153: aload         6
     155: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     160: astore        9
     162: aload         9
     164: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     169: ifeq          225
     172: aload         9
     174: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     179: astore        10
     181: aload         10
     183: checkcast     #39                 // class java/lang/Number
     186: invokevirtual #43                 // Method java/lang/Number.intValue:()I
     189: istore        11
     191: iconst_0
     192: istore        12
     194: iload         11
     196: iconst_2
     197: irem
     198: iconst_1
     199: iload_1
     200: isub
     201: if_icmpne     208
     204: iconst_1
     205: goto          209
     208: iconst_0
     209: ifeq          162
     212: aload         7
     214: aload         10
     216: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     221: pop
     222: goto          162
     225: aload         7
     227: checkcast     #45                 // class java/util/List
     230: nop
     231: astore_3
     232: aload_2
     233: checkcast     #17                 // class java/lang/Iterable
     236: astore        4
     238: iconst_0
     239: istore        5
     241: aload         4
     243: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     248: astore        6
     250: aload_3
     251: checkcast     #17                 // class java/lang/Iterable
     254: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     259: astore        7
     261: new           #19                 // class java/util/ArrayList
     264: dup
     265: aload         4
     267: bipush        10
     269: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     272: aload_3
     273: checkcast     #17                 // class java/lang/Iterable
     276: bipush        10
     278: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     281: invokestatic  #63                 // Method java/lang/Math.min:(II)I
     284: invokespecial #66                 // Method java/util/ArrayList."<init>":(I)V
     287: astore        8
     289: aload         6
     291: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     296: ifeq          368
     299: aload         7
     301: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     306: ifeq          368
     309: aload         8
     311: aload         6
     313: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     318: aload         7
     320: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     325: checkcast     #39                 // class java/lang/Number
     328: invokevirtual #43                 // Method java/lang/Number.intValue:()I
     331: istore        9
     333: checkcast     #39                 // class java/lang/Number
     336: invokevirtual #43                 // Method java/lang/Number.intValue:()I
     339: istore        10
     341: astore        13
     343: iconst_0
     344: istore        11
     346: iload         10
     348: iload         9
     350: isub
     351: invokestatic  #70                 // Method java/lang/Math.abs:(I)I
     354: i2l
     355: invokestatic  #76                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     358: aload         13
     360: swap
     361: invokevirtual #77                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     364: pop
     365: goto          289
     368: aload         8
     370: checkcast     #45                 // class java/util/List
     373: checkcast     #17                 // class java/lang/Iterable
     376: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     379: lreturn

  private static final long solve();
    Code:
       0: invokestatic  #114                // Method readLn:()Ljava/lang/String;
       3: pop
       4: invokestatic  #118                // Method readInts:()Ljava/util/List;
       7: checkcast     #17                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #19                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #66                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #9                  // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          99
      54: aload         6
      56: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #39                 // class java/lang/Number
      70: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      73: istore        8
      75: astore        10
      77: iconst_0
      78: istore        9
      80: iload         8
      82: iconst_1
      83: iand
      84: invokestatic  #123                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      87: aload         10
      89: swap
      90: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      95: pop
      96: goto          44
      99: aload         4
     101: checkcast     #45                 // class java/util/List
     104: nop
     105: astore_0
     106: aload_0
     107: invokeinterface #126,  1          // InterfaceMethod java/util/List.size:()I
     112: istore_1
     113: aload_0
     114: checkcast     #17                 // class java/lang/Iterable
     117: invokestatic  #130                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     120: iload_1
     121: iconst_2
     122: idiv
     123: isub
     124: istore_2
     125: iload_1
     126: iconst_2
     127: irem
     128: ifne          149
     131: iload_2
     132: ifne          177
     135: aload_0
     136: iconst_0
     137: invokestatic  #132                // Method solve:(Ljava/util/List;I)J
     140: aload_0
     141: iconst_1
     142: invokestatic  #132                // Method solve:(Ljava/util/List;I)J
     145: invokestatic  #135                // Method java/lang/Math.min:(JJ)J
     148: lreturn
     149: iconst_0
     150: iload_2
     151: if_icmpgt     167
     154: iload_2
     155: iconst_2
     156: if_icmpge     163
     159: iconst_1
     160: goto          168
     163: iconst_0
     164: goto          168
     167: iconst_0
     168: ifeq          177
     171: aload_0
     172: iload_2
     173: invokestatic  #132                // Method solve:(Ljava/util/List;I)J
     176: lreturn
     177: ldc2_w        #136                // long -1l
     180: lreturn

  public static final void main();
    Code:
       0: invokestatic  #149                // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     35
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: invokestatic  #151                // Method solve:()J
      18: lstore        4
      20: getstatic     #157                // Field java/lang/System.out:Ljava/io/PrintStream;
      23: lload         4
      25: invokevirtual #163                // Method java/io/PrintStream.println:(J)V
      28: nop
      29: iinc          1, 1
      32: goto          6
      35: return

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

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

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

fun ask(or: Boolean, i: Int, j: Int): Int {
	val s = if (or) "or" else "and"
	println("$s ${i + 1} ${j + 1}")
	return readInt()
}

fun main() {
	val (n, k) = readInts()
	val (ands, ors) = List(2) { or -> List(n - 1) { ask(or == 1, 0, it + 1) } }
	val and12 = ask(false, 1, 2)
	val a = IntArray(n)
	for (b in 0..29) {
		val t = 1 shl b
		val maybe0 = ands.all { (it and t) == 0 }
		val maybe1 = ors.all { (it and t) == t }
		val v = if (maybe1 && (!maybe0 || and12 and t == 0)) 1 else 0
		a[0] = a[0] or (v * t)
		for (i in 1 until n) {
			val u = ((if (v == 1) ands[i - 1] else ors[i - 1]) shr b) and 1
			a[i] = a[i] or (u * t)
		}
	}
	a.sort()
	println("finish ${a[k - 1]}")
}

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

Compiled from "d.kt"
public final class codeforces.deltix2021summer.DKt {
  public static final int ask(boolean, int, int);
    Code:
       0: iload_0
       1: ifeq          9
       4: ldc           #8                  // String or
       6: goto          11
       9: ldc           #10                 // String and
      11: astore_3
      12: new           #12                 // class java/lang/StringBuilder
      15: dup
      16: invokespecial #16                 // Method java/lang/StringBuilder."<init>":()V
      19: aload_3
      20: invokevirtual #20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: bipush        32
      25: invokevirtual #23                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      28: iload_1
      29: iconst_1
      30: iadd
      31: invokevirtual #26                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      34: bipush        32
      36: invokevirtual #23                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      39: iload_2
      40: iconst_1
      41: iadd
      42: invokevirtual #26                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      45: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      48: getstatic     #36                 // Field java/lang/System.out:Ljava/io/PrintStream;
      51: swap
      52: invokevirtual #42                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      55: invokestatic  #46                 // Method readInt:()I
      58: ireturn

  public static final void main();
    Code:
       0: invokestatic  #59                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #67                 // class java/lang/Number
      14: invokevirtual #70                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #67                 // class java/lang/Number
      28: invokevirtual #70                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: iconst_2
      33: istore        4
      35: new           #72                 // class java/util/ArrayList
      38: dup
      39: iload         4
      41: invokespecial #75                 // Method java/util/ArrayList."<init>":(I)V
      44: astore        5
      46: iconst_0
      47: istore        6
      49: iload         6
      51: iload         4
      53: if_icmpge     166
      56: iload         6
      58: istore        7
      60: aload         5
      62: iload         7
      64: istore        8
      66: astore        18
      68: iconst_0
      69: istore        9
      71: iload_1
      72: iconst_1
      73: isub
      74: istore        10
      76: new           #72                 // class java/util/ArrayList
      79: dup
      80: iload         10
      82: invokespecial #75                 // Method java/util/ArrayList."<init>":(I)V
      85: astore        11
      87: iconst_0
      88: istore        12
      90: iload         12
      92: iload         10
      94: if_icmpge     147
      97: iload         12
      99: istore        13
     101: aload         11
     103: iload         13
     105: istore        14
     107: astore        15
     109: iconst_0
     110: istore        16
     112: iload         8
     114: iconst_1
     115: if_icmpne     122
     118: iconst_1
     119: goto          123
     122: iconst_0
     123: iconst_0
     124: iload         14
     126: iconst_1
     127: iadd
     128: invokestatic  #77                 // Method ask:(ZII)I
     131: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     134: aload         15
     136: swap
     137: invokevirtual #87                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     140: pop
     141: iinc          12, 1
     144: goto          90
     147: aload         11
     149: checkcast     #61                 // class java/util/List
     152: nop
     153: aload         18
     155: swap
     156: invokevirtual #87                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     159: pop
     160: iinc          6, 1
     163: goto          49
     166: aload         5
     168: checkcast     #61                 // class java/util/List
     171: astore_3
     172: aload_3
     173: iconst_0
     174: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     179: checkcast     #61                 // class java/util/List
     182: astore        4
     184: aload_3
     185: iconst_1
     186: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     191: checkcast     #61                 // class java/util/List
     194: astore        5
     196: iconst_0
     197: iconst_1
     198: iconst_2
     199: invokestatic  #77                 // Method ask:(ZII)I
     202: istore        6
     204: iload_1
     205: newarray       int
     207: astore        7
     209: iconst_0
     210: istore        8
     212: iload         8
     214: bipush        30
     216: if_icmpge     551
     219: iconst_1
     220: iload         8
     222: ishl
     223: istore        9
     225: aload         4
     227: checkcast     #89                 // class java/lang/Iterable
     230: astore        11
     232: iconst_0
     233: istore        12
     235: aload         11
     237: instanceof    #91                 // class java/util/Collection
     240: ifeq          260
     243: aload         11
     245: checkcast     #91                 // class java/util/Collection
     248: invokeinterface #95,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     253: ifeq          260
     256: iconst_1
     257: goto          322
     260: aload         11
     262: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     267: astore        13
     269: aload         13
     271: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     276: ifeq          321
     279: aload         13
     281: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     286: astore        14
     288: aload         14
     290: checkcast     #67                 // class java/lang/Number
     293: invokevirtual #70                 // Method java/lang/Number.intValue:()I
     296: istore        15
     298: iconst_0
     299: istore        16
     301: iload         15
     303: iload         9
     305: iand
     306: ifne          313
     309: iconst_1
     310: goto          314
     313: iconst_0
     314: ifne          269
     317: iconst_0
     318: goto          322
     321: iconst_1
     322: istore        10
     324: aload         5
     326: checkcast     #89                 // class java/lang/Iterable
     329: astore        12
     331: iconst_0
     332: istore        13
     334: aload         12
     336: instanceof    #91                 // class java/util/Collection
     339: ifeq          359
     342: aload         12
     344: checkcast     #91                 // class java/util/Collection
     347: invokeinterface #95,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     352: ifeq          359
     355: iconst_1
     356: goto          423
     359: aload         12
     361: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     366: astore        14
     368: aload         14
     370: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     375: ifeq          422
     378: aload         14
     380: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     385: astore        15
     387: aload         15
     389: checkcast     #67                 // class java/lang/Number
     392: invokevirtual #70                 // Method java/lang/Number.intValue:()I
     395: istore        16
     397: iconst_0
     398: istore        17
     400: iload         16
     402: iload         9
     404: iand
     405: iload         9
     407: if_icmpne     414
     410: iconst_1
     411: goto          415
     414: iconst_0
     415: ifne          368
     418: iconst_0
     419: goto          423
     422: iconst_1
     423: istore        11
     425: iload         11
     427: ifeq          447
     430: iload         10
     432: ifeq          443
     435: iload         6
     437: iload         9
     439: iand
     440: ifne          447
     443: iconst_1
     444: goto          448
     447: iconst_0
     448: istore        12
     450: aload         7
     452: iconst_0
     453: aload         7
     455: iconst_0
     456: iaload
     457: iload         12
     459: iload         9
     461: imul
     462: ior
     463: iastore
     464: iconst_1
     465: istore        13
     467: iload         13
     469: iload_1
     470: if_icmpge     545
     473: iload         12
     475: iconst_1
     476: if_icmpne     499
     479: aload         4
     481: iload         13
     483: iconst_1
     484: isub
     485: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     490: checkcast     #67                 // class java/lang/Number
     493: invokevirtual #70                 // Method java/lang/Number.intValue:()I
     496: goto          516
     499: aload         5
     501: iload         13
     503: iconst_1
     504: isub
     505: invokeinterface #65,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     510: checkcast     #67                 // class java/lang/Number
     513: invokevirtual #70                 // Method java/lang/Number.intValue:()I
     516: iload         8
     518: ishr
     519: iconst_1
     520: iand
     521: istore        14
     523: aload         7
     525: iload         13
     527: aload         7
     529: iload         13
     531: iaload
     532: iload         14
     534: iload         9
     536: imul
     537: ior
     538: iastore
     539: iinc          13, 1
     542: goto          467
     545: iinc          8, 1
     548: goto          212
     551: aload         7
     553: invokestatic  #114                // Method kotlin/collections/ArraysKt.sort:([I)V
     556: new           #12                 // class java/lang/StringBuilder
     559: dup
     560: invokespecial #16                 // Method java/lang/StringBuilder."<init>":()V
     563: ldc           #116                // String finish
     565: invokevirtual #20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     568: aload         7
     570: iload_2
     571: iconst_1
     572: isub
     573: iaload
     574: invokevirtual #26                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     577: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     580: getstatic     #36                 // Field java/lang/System.out:Ljava/io/PrintStream;
     583: swap
     584: invokevirtual #42                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     587: return

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

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

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

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


package codeforces.deltix2021summer

fun main() {
	readLn()
	val strengths = readInts().map { it.toModular() }
	val n = strengths.size
	val probWin = Array(n) { i -> Array(n) { j -> strengths[i] / (strengths[i] + strengths[j]) } }
	val masks = 1 shl n
	val pScc = Array(masks) { 1.toModular() }
	var ans = 0.toModular()
	for (mask in 1 until masks) {
		if (mask.countOneBits() == 1) continue
		var top = (mask - 1) and mask
		var rest = 1L
		while (top > 0) {
			var thisTop = pScc[top]
			for (i in 0 until n) {
				if (!top.hasBit(i)) continue
				for (j in 0 until n) {
					if (top.hasBit(j) || !mask.hasBit(j)) continue
					thisTop *= probWin[i][j]
				}
			}
			if (mask == masks - 1) ans += top.countOneBits() * thisTop
			rest -= thisTop.x
			top = (top - 1) and mask
		}
		pScc[mask] = rest.toModular()
	}
	println(ans + n * pScc.last())
}

private fun Int.toModular() = Modular(this)//toDouble()
private fun Long.toModular() = Modular(this)
private class Modular {
	companion object {
		const val M = 1_000_000_007
	}
	val x: Int
	@Suppress("ConvertSecondaryConstructorToPrimary")
	constructor(value: Int) { x = (value % M).let { if (it < 0) it + M else it } }
	@Suppress("ConvertSecondaryConstructorToPrimary")
	constructor(value: Long) { x = (value % M).toInt().let { if (it < 0) it + M else it } }
	operator fun plus(that: Modular) = Modular((x + that.x) % M)
	operator fun minus(that: Modular) = Modular((x + M - that.x) % M)
	operator fun times(that: Modular) = (x.toLong() * that.x % M).toInt().toModular()
	private fun modInverse() = Modular(x.toBigInteger().modInverse(M.toBigInteger()).toInt())
	operator fun div(that: Modular) = times(that.modInverse())
	override fun toString() = x.toString()
}
private operator fun Int.plus(that: Modular) = Modular(this) + that
private operator fun Int.minus(that: Modular) = Modular(this) - that
private operator fun Int.times(that: Modular) = Modular(this) * that
private operator fun Int.div(that: Modular) = Modular(this) / that

private fun Int.bit(index: Int) = shr(index) and 1
private fun Int.hasBit(index: Int) = bit(index) != 0

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

Compiled from "f.kt"
public final class codeforces.deltix2021summer.FKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: pop
       4: invokestatic  #14                 // Method readInts:()Ljava/util/List;
       7: checkcast     #16                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #18                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #30                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         6
      56: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #46                 // class java/lang/Number
      70: invokevirtual #50                 // Method java/lang/Number.intValue:()I
      73: istore        8
      75: astore        13
      77: iconst_0
      78: istore        9
      80: iload         8
      82: invokestatic  #54                 // Method toModular:(I)Lcodeforces/deltix2021summer/Modular;
      85: aload         13
      87: swap
      88: invokeinterface #58,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         4
      99: checkcast     #60                 // class java/util/List
     102: nop
     103: astore_0
     104: aload_0
     105: invokeinterface #63,  1           // InterfaceMethod java/util/List.size:()I
     110: istore_1
     111: iconst_0
     112: istore_3
     113: iload_1
     114: anewarray     #65                 // class "[Lcodeforces/deltix2021summer/Modular;"
     117: astore        4
     119: iload_3
     120: iload_1
     121: if_icmpge     217
     124: iload_3
     125: istore        5
     127: aload         4
     129: iload         5
     131: iconst_0
     132: istore        6
     134: iload_1
     135: anewarray     #67                 // class codeforces/deltix2021summer/Modular
     138: astore        7
     140: istore        14
     142: astore        13
     144: iload         6
     146: iload_1
     147: if_icmpge     204
     150: iload         6
     152: istore        8
     154: aload         7
     156: iload         8
     158: aload_0
     159: iload         5
     161: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     166: checkcast     #67                 // class codeforces/deltix2021summer/Modular
     169: aload_0
     170: iload         5
     172: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     177: checkcast     #67                 // class codeforces/deltix2021summer/Modular
     180: aload_0
     181: iload         8
     183: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     188: checkcast     #67                 // class codeforces/deltix2021summer/Modular
     191: invokevirtual #75                 // Method codeforces/deltix2021summer/Modular.plus:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     194: invokevirtual #78                 // Method codeforces/deltix2021summer/Modular.div:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     197: aastore
     198: iinc          6, 1
     201: goto          144
     204: aload         13
     206: iload         14
     208: aload         7
     210: aastore
     211: iinc          3, 1
     214: goto          119
     217: aload         4
     219: astore_2
     220: iconst_1
     221: iload_1
     222: ishl
     223: istore_3
     224: iconst_0
     225: istore        5
     227: iload_3
     228: anewarray     #67                 // class codeforces/deltix2021summer/Modular
     231: astore        6
     233: iload         5
     235: iload_3
     236: if_icmpge     258
     239: iload         5
     241: istore        7
     243: aload         6
     245: iload         7
     247: iconst_1
     248: invokestatic  #54                 // Method toModular:(I)Lcodeforces/deltix2021summer/Modular;
     251: aastore
     252: iinc          5, 1
     255: goto          233
     258: aload         6
     260: astore        4
     262: iconst_0
     263: invokestatic  #54                 // Method toModular:(I)Lcodeforces/deltix2021summer/Modular;
     266: astore        5
     268: iconst_1
     269: istore        6
     271: iload         6
     273: iload_3
     274: if_icmpge     451
     277: iload         6
     279: invokestatic  #84                 // Method java/lang/Integer.bitCount:(I)I
     282: iconst_1
     283: if_icmpeq     445
     286: iload         6
     288: iconst_1
     289: isub
     290: iload         6
     292: iand
     293: istore        7
     295: lconst_1
     296: lstore        8
     298: iload         7
     300: ifle          435
     303: aload         4
     305: iload         7
     307: aaload
     308: astore        10
     310: iconst_0
     311: istore        11
     313: iload         11
     315: iload_1
     316: if_icmpge     387
     319: iload         7
     321: iload         11
     323: invokestatic  #88                 // Method hasBit:(II)Z
     326: ifeq          381
     329: iconst_0
     330: istore        12
     332: iload         12
     334: iload_1
     335: if_icmpge     381
     338: iload         7
     340: iload         12
     342: invokestatic  #88                 // Method hasBit:(II)Z
     345: ifne          375
     348: iload         6
     350: iload         12
     352: invokestatic  #88                 // Method hasBit:(II)Z
     355: ifne          361
     358: goto          375
     361: aload         10
     363: aload_2
     364: iload         11
     366: aaload
     367: iload         12
     369: aaload
     370: invokevirtual #91                 // Method codeforces/deltix2021summer/Modular.times:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     373: astore        10
     375: iinc          12, 1
     378: goto          332
     381: iinc          11, 1
     384: goto          313
     387: iload         6
     389: iload_3
     390: iconst_1
     391: isub
     392: if_icmpne     412
     395: aload         5
     397: iload         7
     399: invokestatic  #84                 // Method java/lang/Integer.bitCount:(I)I
     402: aload         10
     404: invokestatic  #94                 // Method times:(ILcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     407: invokevirtual #75                 // Method codeforces/deltix2021summer/Modular.plus:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     410: astore        5
     412: lload         8
     414: aload         10
     416: invokevirtual #97                 // Method codeforces/deltix2021summer/Modular.getX:()I
     419: i2l
     420: lsub
     421: lstore        8
     423: iload         7
     425: iconst_1
     426: isub
     427: iload         6
     429: iand
     430: istore        7
     432: goto          298
     435: aload         4
     437: iload         6
     439: lload         8
     441: invokestatic  #100                // Method toModular:(J)Lcodeforces/deltix2021summer/Modular;
     444: aastore
     445: iinc          6, 1
     448: goto          271
     451: aload         5
     453: iload_1
     454: aload         4
     456: invokestatic  #106                // Method kotlin/collections/ArraysKt.last:([Ljava/lang/Object;)Ljava/lang/Object;
     459: checkcast     #67                 // class codeforces/deltix2021summer/Modular
     462: invokestatic  #94                 // Method times:(ILcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     465: invokevirtual #75                 // Method codeforces/deltix2021summer/Modular.plus:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
     468: getstatic     #112                // Field java/lang/System.out:Ljava/io/PrintStream;
     471: swap
     472: invokevirtual #118                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     475: return

  private static final codeforces.deltix2021summer.Modular toModular(int);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: iload_0
       5: invokespecial #148                // Method codeforces/deltix2021summer/Modular."<init>":(I)V
       8: areturn

  private static final codeforces.deltix2021summer.Modular toModular(long);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: lload_0
       5: invokespecial #152                // Method codeforces/deltix2021summer/Modular."<init>":(J)V
       8: areturn

  private static final codeforces.deltix2021summer.Modular plus(int, codeforces.deltix2021summer.Modular);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: iload_0
       5: invokespecial #148                // Method codeforces/deltix2021summer/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #75                 // Method codeforces/deltix2021summer/Modular.plus:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
      12: areturn

  private static final codeforces.deltix2021summer.Modular minus(int, codeforces.deltix2021summer.Modular);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: iload_0
       5: invokespecial #148                // Method codeforces/deltix2021summer/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #157                // Method codeforces/deltix2021summer/Modular.minus:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
      12: areturn

  private static final codeforces.deltix2021summer.Modular times(int, codeforces.deltix2021summer.Modular);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: iload_0
       5: invokespecial #148                // Method codeforces/deltix2021summer/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #91                 // Method codeforces/deltix2021summer/Modular.times:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
      12: areturn

  private static final codeforces.deltix2021summer.Modular div(int, codeforces.deltix2021summer.Modular);
    Code:
       0: new           #67                 // class codeforces/deltix2021summer/Modular
       3: dup
       4: iload_0
       5: invokespecial #148                // Method codeforces/deltix2021summer/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #78                 // Method codeforces/deltix2021summer/Modular.div:(Lcodeforces/deltix2021summer/Modular;)Lcodeforces/deltix2021summer/Modular;
      12: areturn

  private static final int bit(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: ishr
       3: iconst_1
       4: iand
       5: ireturn

  private static final boolean hasBit(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: invokestatic  #166                // Method bit:(II)I
       5: ifeq          12
       8: iconst_1
       9: goto          13
      12: iconst_0
      13: ireturn

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

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

  public static final codeforces.deltix2021summer.Modular access$toModular(int);
    Code:
       0: iload_0
       1: invokestatic  #54                 // Method toModular:(I)Lcodeforces/deltix2021summer/Modular;
       4: areturn
}


package codeforces.round580

fun main() {
	val n = readInt()
	val nei = List(n) { mutableListOf<Int>() }
	repeat(n - 1) {
		val (a, b) = readInts().map { it - 1 }
		nei[a].add(b)
		nei[b].add(a)
	}
	nei.indices.flatMap { v ->
		val (sizes, vertices) = nei[v].map { Pair(dfs(it, setOf(v), 0, nei), it) }.sortedBy { it.first }.unzip()
		sizes.indices.map { i ->
			val size = sizes.take(i).sum()
			Pair((size + 1) * (n - size)) { dfs(v, vertices.drop(i), 1, nei); dfs(v, vertices.take(i), size + 1, nei) }
		}
	}.maxByOrNull { it.first }?.second?.invoke()
}

private fun dfs(v: Int, p: Collection<Int>, k: Int, nei: List<List<Int>>): Int {
	var sum = 1
	for (u in nei[v].minus(p)) {
		if (k > 0) println("${u + 1} ${v + 1} ${k * sum}")
		sum += dfs(u, setOf(v), k, nei)
	}
	return sum
}

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

Compiled from "Comparisons.kt"
public final class codeforces.round580.DKt$main$lambda$7$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public codeforces.round580.DKt$main$lambda$7$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

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

Compiled from "d.kt"
public final class codeforces.round580.DKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: new           #12                 // class java/util/ArrayList
       7: dup
       8: iload_0
       9: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
      12: astore_2
      13: iconst_0
      14: istore_3
      15: iload_3
      16: iload_0
      17: if_icmpge     57
      20: iload_3
      21: istore        4
      23: aload_2
      24: iload         4
      26: istore        5
      28: astore        26
      30: iconst_0
      31: istore        6
      33: new           #12                 // class java/util/ArrayList
      36: dup
      37: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
      40: checkcast     #20                 // class java/util/List
      43: nop
      44: aload         26
      46: swap
      47: invokevirtual #24                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      50: pop
      51: iinc          3, 1
      54: goto          15
      57: aload_2
      58: checkcast     #20                 // class java/util/List
      61: astore_1
      62: iload_0
      63: iconst_1
      64: isub
      65: istore_2
      66: iconst_0
      67: istore_3
      68: iload_3
      69: iload_2
      70: if_icmpge     271
      73: iload_3
      74: istore        4
      76: iconst_0
      77: istore        5
      79: invokestatic  #28                 // Method readInts:()Ljava/util/List;
      82: checkcast     #30                 // class java/lang/Iterable
      85: astore        6
      87: iconst_0
      88: istore        7
      90: aload         6
      92: astore        8
      94: new           #12                 // class java/util/ArrayList
      97: dup
      98: aload         6
     100: bipush        10
     102: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     105: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     108: checkcast     #38                 // class java/util/Collection
     111: astore        9
     113: iconst_0
     114: istore        10
     116: aload         8
     118: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     123: astore        11
     125: aload         11
     127: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     132: ifeq          180
     135: aload         11
     137: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     142: astore        12
     144: aload         9
     146: aload         12
     148: checkcast     #54                 // class java/lang/Number
     151: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     154: istore        13
     156: astore        14
     158: iconst_0
     159: istore        15
     161: iload         13
     163: iconst_1
     164: isub
     165: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     168: aload         14
     170: swap
     171: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     176: pop
     177: goto          125
     180: aload         9
     182: checkcast     #20                 // class java/util/List
     185: nop
     186: astore        16
     188: aload         16
     190: iconst_0
     191: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     196: checkcast     #54                 // class java/lang/Number
     199: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     202: istore        6
     204: aload         16
     206: iconst_1
     207: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     212: checkcast     #54                 // class java/lang/Number
     215: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     218: istore        7
     220: aload_1
     221: iload         6
     223: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     228: checkcast     #20                 // class java/util/List
     231: iload         7
     233: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     236: invokeinterface #69,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     241: pop
     242: aload_1
     243: iload         7
     245: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     250: checkcast     #20                 // class java/util/List
     253: iload         6
     255: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     258: invokeinterface #69,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     263: pop
     264: nop
     265: iinc          3, 1
     268: goto          68
     271: aload_1
     272: checkcast     #38                 // class java/util/Collection
     275: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     278: checkcast     #30                 // class java/lang/Iterable
     281: astore_3
     282: iconst_0
     283: istore        4
     285: aload_3
     286: astore        5
     288: new           #12                 // class java/util/ArrayList
     291: dup
     292: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
     295: checkcast     #38                 // class java/util/Collection
     298: astore        6
     300: iconst_0
     301: istore        7
     303: aload         5
     305: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     310: astore        8
     312: aload         8
     314: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     319: ifeq          697
     322: aload         8
     324: checkcast     #75                 // class kotlin/collections/IntIterator
     327: invokevirtual #78                 // Method kotlin/collections/IntIterator.nextInt:()I
     330: istore        9
     332: iload         9
     334: istore        10
     336: iconst_0
     337: istore        11
     339: aload_1
     340: iload         10
     342: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     347: checkcast     #30                 // class java/lang/Iterable
     350: astore        12
     352: iconst_0
     353: istore        13
     355: aload         12
     357: astore        14
     359: new           #12                 // class java/util/ArrayList
     362: dup
     363: aload         12
     365: bipush        10
     367: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     370: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     373: checkcast     #38                 // class java/util/Collection
     376: astore        15
     378: iconst_0
     379: istore        16
     381: aload         14
     383: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     388: astore        17
     390: aload         17
     392: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     397: ifeq          471
     400: aload         17
     402: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     407: astore        18
     409: aload         15
     411: aload         18
     413: checkcast     #54                 // class java/lang/Number
     416: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     419: istore        19
     421: astore        20
     423: iconst_0
     424: istore        21
     426: new           #80                 // class kotlin/Pair
     429: dup
     430: iload         19
     432: iload         10
     434: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     437: invokestatic  #86                 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;
     440: checkcast     #38                 // class java/util/Collection
     443: iconst_0
     444: aload_1
     445: invokestatic  #90                 // Method dfs:(ILjava/util/Collection;ILjava/util/List;)I
     448: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     451: iload         19
     453: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     456: invokespecial #93                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     459: aload         20
     461: swap
     462: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     467: pop
     468: goto          390
     471: aload         15
     473: checkcast     #20                 // class java/util/List
     476: nop
     477: checkcast     #30                 // class java/lang/Iterable
     480: astore        12
     482: nop
     483: iconst_0
     484: istore        13
     486: aload         12
     488: new           #95                 // class codeforces/round580/DKt$main$lambda$7$$inlined$sortedBy$1
     491: dup
     492: invokespecial #96                 // Method codeforces/round580/DKt$main$lambda$7$$inlined$sortedBy$1."<init>":()V
     495: checkcast     #98                 // class java/util/Comparator
     498: invokestatic  #102                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     501: checkcast     #30                 // class java/lang/Iterable
     504: invokestatic  #106                // Method kotlin/collections/CollectionsKt.unzip:(Ljava/lang/Iterable;)Lkotlin/Pair;
     507: astore        22
     509: aload         22
     511: invokevirtual #109                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     514: checkcast     #20                 // class java/util/List
     517: astore        12
     519: aload         22
     521: invokevirtual #112                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     524: checkcast     #20                 // class java/util/List
     527: astore        13
     529: aload         12
     531: checkcast     #38                 // class java/util/Collection
     534: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     537: checkcast     #30                 // class java/lang/Iterable
     540: astore        14
     542: iconst_0
     543: istore        15
     545: aload         14
     547: astore        16
     549: new           #12                 // class java/util/ArrayList
     552: dup
     553: aload         14
     555: bipush        10
     557: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     560: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
     563: checkcast     #38                 // class java/util/Collection
     566: astore        17
     568: iconst_0
     569: istore        18
     571: aload         16
     573: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     578: astore        19
     580: aload         19
     582: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     587: ifeq          674
     590: aload         19
     592: checkcast     #75                 // class kotlin/collections/IntIterator
     595: invokevirtual #78                 // Method kotlin/collections/IntIterator.nextInt:()I
     598: istore        21
     600: aload         17
     602: iload         21
     604: istore        23
     606: astore        20
     608: iconst_0
     609: istore        24
     611: aload         12
     613: checkcast     #30                 // class java/lang/Iterable
     616: iload         23
     618: invokestatic  #116                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     621: checkcast     #30                 // class java/lang/Iterable
     624: invokestatic  #120                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     627: istore        25
     629: new           #80                 // class kotlin/Pair
     632: dup
     633: iload         25
     635: iconst_1
     636: iadd
     637: iload_0
     638: iload         25
     640: isub
     641: imul
     642: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     645: iload         10
     647: aload         13
     649: iload         23
     651: aload_1
     652: iload         25
     654: invokedynamic #139,  0            // InvokeDynamic #0:invoke:(ILjava/util/List;ILjava/util/List;I)Lkotlin/jvm/functions/Function0;
     659: invokespecial #93                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     662: aload         20
     664: swap
     665: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     670: pop
     671: goto          580
     674: aload         17
     676: checkcast     #20                 // class java/util/List
     679: nop
     680: checkcast     #30                 // class java/lang/Iterable
     683: nop
     684: astore        10
     686: aload         6
     688: aload         10
     690: invokestatic  #143                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     693: pop
     694: goto          312
     697: aload         6
     699: checkcast     #20                 // class java/util/List
     702: nop
     703: checkcast     #30                 // class java/lang/Iterable
     706: astore_3
     707: nop
     708: iconst_0
     709: istore        4
     711: aload_3
     712: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     717: astore        5
     719: aload         5
     721: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     726: ifne          733
     729: aconst_null
     730: goto          839
     733: aload         5
     735: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     740: astore        6
     742: aload         5
     744: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     749: ifne          757
     752: aload         6
     754: goto          839
     757: aload         6
     759: checkcast     #80                 // class kotlin/Pair
     762: astore        7
     764: iconst_0
     765: istore        8
     767: aload         7
     769: invokevirtual #146                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     772: checkcast     #54                 // class java/lang/Number
     775: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     778: istore        7
     780: aload         5
     782: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     787: astore        8
     789: aload         8
     791: checkcast     #80                 // class kotlin/Pair
     794: astore        9
     796: iconst_0
     797: istore        10
     799: aload         9
     801: invokevirtual #146                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     804: checkcast     #54                 // class java/lang/Number
     807: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     810: istore        9
     812: iload         7
     814: iload         9
     816: if_icmpge     827
     819: aload         8
     821: astore        6
     823: iload         9
     825: istore        7
     827: aload         5
     829: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     834: ifne          780
     837: aload         6
     839: checkcast     #80                 // class kotlin/Pair
     842: astore_2
     843: aload_2
     844: ifnull        869
     847: aload_2
     848: invokevirtual #149                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     851: checkcast     #151                // class kotlin/jvm/functions/Function0
     854: astore_3
     855: aload_3
     856: ifnull        869
     859: aload_3
     860: invokeinterface #153,  1          // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;
     865: checkcast     #59                 // class java/lang/Integer
     868: pop
     869: return

  private static final int dfs(int, java.util.Collection<java.lang.Integer>, int, java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: iconst_1
       1: istore        4
       3: aload_3
       4: iload_0
       5: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/Iterable
      13: aload_1
      14: checkcast     #30                 // class java/lang/Iterable
      17: invokestatic  #203                // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
      20: invokeinterface #204,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      25: astore        5
      27: aload         5
      29: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          128
      37: aload         5
      39: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      44: checkcast     #54                 // class java/lang/Number
      47: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      50: istore        6
      52: iload_2
      53: ifle          103
      56: new           #206                // class java/lang/StringBuilder
      59: dup
      60: invokespecial #207                // Method java/lang/StringBuilder."<init>":()V
      63: iload         6
      65: iconst_1
      66: iadd
      67: invokevirtual #211                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      70: bipush        32
      72: invokevirtual #214                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      75: iload_0
      76: iconst_1
      77: iadd
      78: invokevirtual #211                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      81: bipush        32
      83: invokevirtual #214                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      86: iload_2
      87: iload         4
      89: imul
      90: invokevirtual #211                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      93: invokevirtual #218                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      96: getstatic     #224                // Field java/lang/System.out:Ljava/io/PrintStream;
      99: swap
     100: invokevirtual #230                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     103: iload         4
     105: iload         6
     107: iload_0
     108: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     111: invokestatic  #86                 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;
     114: checkcast     #38                 // class java/util/Collection
     117: iload_2
     118: aload_3
     119: invokestatic  #90                 // Method dfs:(ILjava/util/Collection;ILjava/util/List;)I
     122: iadd
     123: istore        4
     125: goto          27
     128: iload         4
     130: ireturn

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

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

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

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

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

  private static final int main$lambda$7$lambda$6$lambda$5(int, java.util.List, int, java.util.List, int);
    Code:
       0: iload_0
       1: aload_1
       2: checkcast     #30                 // class java/lang/Iterable
       5: iload_2
       6: invokestatic  #278                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
       9: checkcast     #38                 // class java/util/Collection
      12: iconst_1
      13: aload_3
      14: invokestatic  #90                 // Method dfs:(ILjava/util/Collection;ILjava/util/List;)I
      17: pop
      18: iload_0
      19: aload_1
      20: checkcast     #30                 // class java/lang/Iterable
      23: iload_2
      24: invokestatic  #116                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      27: checkcast     #38                 // class java/util/Collection
      30: iload         4
      32: iconst_1
      33: iadd
      34: aload_3
      35: invokestatic  #90                 // Method dfs:(ILjava/util/Collection;ILjava/util/List;)I
      38: ireturn
}