package codeforces.codeton6

import java.util.BitSet

private fun solve(): Int {
	readln()
	val a = readInts()
	val highMex = (a.size + 1).takeHighestOneBit() * 2
	val mark = IntArray(a.size + 1) { -1 }
	val memo = List(highMex) { BitSet() }
	val dp = mutableListOf(BitSet())
	val (dpMax, dpSum) = List(2) { IntArray(a.size + 1) { 0 } }
	dp[0][0] = true
	dpSum[0] = 1
	var leastAbsent = 1
	for (i in a.indices) {
		val dpCurrent = dp[i].clone() as BitSet
		var mex = 0
		for (j in i downTo 0) {
			mark[a[j]] = i
			if (a[j] == mex) {
				while (mark[mex] == i) mex++
				val t = (dpMax[j] or mex).takeHighestOneBit() * 2 - 1
				if (leastAbsent > t) continue
				val memoJ = memo[dpSum[j]]
				if (memoJ[mex]) continue
				memoJ[mex] = true
				val dpJ = dp[j]
				for (k in 0..dpMax[j]) if (dpJ[k]) dpCurrent[k xor mex] = true
				while (dpCurrent[leastAbsent]) leastAbsent++
			}
		}
		dp.add(dpCurrent)
		dpSum[i + 1] = dpCurrent.cardinality()
		dpMax[i + 1] = dpCurrent.length() - 1
	}
	return dpMax.last()
}

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

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

Compiled from "e.kt"
public final class codeforces.codeton6.EKt {
  private static final int solve();
    Code:
       0: invokestatic  #12                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: pop
       4: invokestatic  #16                 // Method readInts:()Ljava/util/List;
       7: astore_0
       8: aload_0
       9: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
      14: iconst_1
      15: iadd
      16: invokestatic  #27                 // Method java/lang/Integer.highestOneBit:(I)I
      19: iconst_2
      20: imul
      21: istore_1
      22: iconst_0
      23: istore_3
      24: aload_0
      25: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
      30: iconst_1
      31: iadd
      32: istore        4
      34: iload         4
      36: newarray       int
      38: astore        5
      40: iload_3
      41: iload         4
      43: if_icmpge     61
      46: iload_3
      47: istore        6
      49: aload         5
      51: iload         6
      53: iconst_m1
      54: iastore
      55: iinc          3, 1
      58: goto          40
      61: aload         5
      63: astore_2
      64: new           #29                 // class java/util/ArrayList
      67: dup
      68: iload_1
      69: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
      72: astore        4
      74: iconst_0
      75: istore        5
      77: iload         5
      79: iload_1
      80: if_icmpge     118
      83: iload         5
      85: istore        6
      87: aload         4
      89: iload         6
      91: istore        7
      93: astore        19
      95: iconst_0
      96: istore        8
      98: new           #35                 // class java/util/BitSet
     101: dup
     102: invokespecial #38                 // Method java/util/BitSet."<init>":()V
     105: aload         19
     107: swap
     108: invokevirtual #42                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     111: pop
     112: iinc          5, 1
     115: goto          77
     118: aload         4
     120: checkcast     #18                 // class java/util/List
     123: astore_3
     124: iconst_1
     125: anewarray     #35                 // class java/util/BitSet
     128: astore        5
     130: aload         5
     132: iconst_0
     133: new           #35                 // class java/util/BitSet
     136: dup
     137: invokespecial #38                 // Method java/util/BitSet."<init>":()V
     140: aastore
     141: aload         5
     143: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     146: astore        4
     148: iconst_2
     149: istore        6
     151: new           #29                 // class java/util/ArrayList
     154: dup
     155: iload         6
     157: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
     160: astore        7
     162: iconst_0
     163: istore        8
     165: iload         8
     167: iload         6
     169: if_icmpge     244
     172: iload         8
     174: istore        9
     176: aload         7
     178: iload         9
     180: istore        10
     182: astore        19
     184: iconst_0
     185: istore        11
     187: iconst_0
     188: istore        12
     190: aload_0
     191: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
     196: iconst_1
     197: iadd
     198: istore        13
     200: iload         13
     202: newarray       int
     204: astore        14
     206: iload         12
     208: iload         13
     210: if_icmpge     229
     213: iload         12
     215: istore        15
     217: aload         14
     219: iload         15
     221: iconst_0
     222: iastore
     223: iinc          12, 1
     226: goto          206
     229: aload         14
     231: aload         19
     233: swap
     234: invokevirtual #42                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     237: pop
     238: iinc          8, 1
     241: goto          165
     244: aload         7
     246: checkcast     #18                 // class java/util/List
     249: astore        5
     251: aload         5
     253: iconst_0
     254: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     259: checkcast     #54                 // class "[I"
     262: astore        6
     264: aload         5
     266: iconst_1
     267: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     272: checkcast     #54                 // class "[I"
     275: astore        7
     277: aload         4
     279: iconst_0
     280: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     285: checkcast     #35                 // class java/util/BitSet
     288: iconst_0
     289: iconst_1
     290: invokevirtual #58                 // Method java/util/BitSet.set:(IZ)V
     293: aload         7
     295: iconst_0
     296: iconst_1
     297: iastore
     298: iconst_1
     299: istore        8
     301: iconst_0
     302: istore        9
     304: aload_0
     305: checkcast     #60                 // class java/util/Collection
     308: invokeinterface #61,  1           // InterfaceMethod java/util/Collection.size:()I
     313: istore        10
     315: iload         9
     317: iload         10
     319: if_icmpge     600
     322: aload         4
     324: iload         9
     326: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     331: checkcast     #35                 // class java/util/BitSet
     334: invokevirtual #65                 // Method java/util/BitSet.clone:()Ljava/lang/Object;
     337: dup
     338: ldc           #67                 // String null cannot be cast to non-null type java.util.BitSet
     340: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     343: checkcast     #35                 // class java/util/BitSet
     346: astore        11
     348: iconst_0
     349: istore        12
     351: iload         9
     353: istore        13
     355: iconst_m1
     356: iload         13
     358: if_icmpge     558
     361: aload_2
     362: aload_0
     363: iload         13
     365: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     370: checkcast     #75                 // class java/lang/Number
     373: invokevirtual #78                 // Method java/lang/Number.intValue:()I
     376: iload         9
     378: iastore
     379: aload_0
     380: iload         13
     382: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     387: checkcast     #75                 // class java/lang/Number
     390: invokevirtual #78                 // Method java/lang/Number.intValue:()I
     393: iload         12
     395: if_icmpne     552
     398: aload_2
     399: iload         12
     401: iaload
     402: iload         9
     404: if_icmpne     413
     407: iinc          12, 1
     410: goto          398
     413: aload         6
     415: iload         13
     417: iaload
     418: iload         12
     420: ior
     421: invokestatic  #27                 // Method java/lang/Integer.highestOneBit:(I)I
     424: iconst_2
     425: imul
     426: iconst_1
     427: isub
     428: istore        14
     430: iload         8
     432: iload         14
     434: if_icmpgt     552
     437: aload_3
     438: aload         7
     440: iload         13
     442: iaload
     443: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     448: checkcast     #35                 // class java/util/BitSet
     451: astore        15
     453: aload         15
     455: iload         12
     457: invokevirtual #81                 // Method java/util/BitSet.get:(I)Z
     460: ifne          552
     463: aload         15
     465: iload         12
     467: iconst_1
     468: invokevirtual #58                 // Method java/util/BitSet.set:(IZ)V
     471: aload         4
     473: iload         13
     475: invokeinterface #52,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     480: checkcast     #35                 // class java/util/BitSet
     483: astore        16
     485: iconst_0
     486: istore        17
     488: aload         6
     490: iload         13
     492: iaload
     493: istore        18
     495: iload         17
     497: iload         18
     499: if_icmpgt     536
     502: aload         16
     504: iload         17
     506: invokevirtual #81                 // Method java/util/BitSet.get:(I)Z
     509: ifeq          523
     512: aload         11
     514: iload         17
     516: iload         12
     518: ixor
     519: iconst_1
     520: invokevirtual #58                 // Method java/util/BitSet.set:(IZ)V
     523: iload         17
     525: iload         18
     527: if_icmpeq     536
     530: iinc          17, 1
     533: goto          502
     536: aload         11
     538: iload         8
     540: invokevirtual #81                 // Method java/util/BitSet.get:(I)Z
     543: ifeq          552
     546: iinc          8, 1
     549: goto          536
     552: iinc          13, -1
     555: goto          355
     558: aload         4
     560: aload         11
     562: invokeinterface #82,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     567: pop
     568: aload         7
     570: iload         9
     572: iconst_1
     573: iadd
     574: aload         11
     576: invokevirtual #85                 // Method java/util/BitSet.cardinality:()I
     579: iastore
     580: aload         6
     582: iload         9
     584: iconst_1
     585: iadd
     586: aload         11
     588: invokevirtual #88                 // Method java/util/BitSet.length:()I
     591: iconst_1
     592: isub
     593: iastore
     594: iinc          9, 1
     597: goto          315
     600: aload         6
     602: invokestatic  #94                 // Method kotlin/collections/ArraysKt.last:([I)I
     605: ireturn

  public static final void main();
    Code:
       0: invokestatic  #122                // 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  #124                // Method solve:()I
      18: istore        4
      20: getstatic     #130                // Field java/lang/System.out:Ljava/io/PrintStream;
      23: iload         4
      25: invokevirtual #135                // Method java/io/PrintStream.println:(I)V
      28: nop
      29: iinc          1, 1
      32: goto          6
      35: return

  private static final int readInt();
    Code:
       0: invokestatic  #12                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: invokestatic  #140                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

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

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


package codeforces.codeton6

private fun solve(): Int {
	readln()
	val a = readInts()
	val mark = IntArray(a.size + 1) { -1 }
	val dp0 = mutableSetOf(0)
	val dp = MutableList(a.size + 1) { dp0 }
	val dpMax = IntArray(a.size + 1) { 0 }
	val dpHashCode = IntArray(a.size + 1) { 0 }
	val used = mutableSetOf<Long>()
	var leastAbsent = 1
	for (i in a.indices) {
		var mex = 0
		val dpCurrent = dp[i].toMutableSet()
		dp[i + 1] = dpCurrent
		for (j in i downTo 0) {
			val aj = a[j]
			mark[aj] = i
			if (aj == mex) {
				while (mark[mex] == i) mex++
				//println("${dp[j]} xor $mex}")
				val t = dpMax[j] or mex
					.let { (1 shl it.countSignificantBits()) - 1 }
				if (leastAbsent > t) continue
				val code = (dpHashCode[j].toLong() shl 32) or mex.toLong()
				if (!used.add(code)) continue
				for (v in dp[j]) dpCurrent.add(v xor mex)
				while (leastAbsent in dpCurrent) leastAbsent++
			}
		}
		dpMax[i + 1] = dpCurrent.max()
		dpHashCode[i + 1] = dpCurrent.hashCode()
	}
	return dpMax.last()
}

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

private fun readInt() = readln().toInt()
private fun readStrings() = readln().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun Int.countSignificantBits() = Int.SIZE_BITS - Integer.numberOfLeadingZeros(this)

Compiled from "e_tl.kt"
public final class codeforces.codeton6.E_tlKt {
  private static final int solve();
    Code:
       0: invokestatic  #12                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: pop
       4: invokestatic  #16                 // Method readInts:()Ljava/util/List;
       7: astore_0
       8: iconst_0
       9: istore_2
      10: aload_0
      11: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
      16: iconst_1
      17: iadd
      18: istore_3
      19: iload_3
      20: newarray       int
      22: astore        4
      24: iload_2
      25: iload_3
      26: if_icmpge     44
      29: iload_2
      30: istore        5
      32: aload         4
      34: iload         5
      36: iconst_m1
      37: iastore
      38: iinc          2, 1
      41: goto          24
      44: aload         4
      46: astore_1
      47: iconst_1
      48: anewarray     #23                 // class java/lang/Integer
      51: astore_3
      52: aload_3
      53: iconst_0
      54: iconst_0
      55: invokestatic  #27                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      58: aastore
      59: aload_3
      60: invokestatic  #33                 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      63: astore_2
      64: aload_0
      65: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
      70: iconst_1
      71: iadd
      72: istore        4
      74: new           #35                 // class java/util/ArrayList
      77: dup
      78: iload         4
      80: invokespecial #39                 // Method java/util/ArrayList."<init>":(I)V
      83: astore        5
      85: iconst_0
      86: istore        6
      88: iload         6
      90: iload         4
      92: if_icmpge     124
      95: iload         6
      97: istore        7
      99: aload         5
     101: iload         7
     103: istore        8
     105: astore        19
     107: iconst_0
     108: istore        9
     110: aload_2
     111: aload         19
     113: swap
     114: invokevirtual #43                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     117: pop
     118: iinc          6, 1
     121: goto          88
     124: aload         5
     126: checkcast     #18                 // class java/util/List
     129: astore_3
     130: iconst_0
     131: istore        5
     133: aload_0
     134: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
     139: iconst_1
     140: iadd
     141: istore        6
     143: iload         6
     145: newarray       int
     147: astore        7
     149: iload         5
     151: iload         6
     153: if_icmpge     172
     156: iload         5
     158: istore        8
     160: aload         7
     162: iload         8
     164: iconst_0
     165: iastore
     166: iinc          5, 1
     169: goto          149
     172: aload         7
     174: astore        4
     176: iconst_0
     177: istore        6
     179: aload_0
     180: invokeinterface #21,  1           // InterfaceMethod java/util/List.size:()I
     185: iconst_1
     186: iadd
     187: istore        7
     189: iload         7
     191: newarray       int
     193: astore        8
     195: iload         6
     197: iload         7
     199: if_icmpge     218
     202: iload         6
     204: istore        9
     206: aload         8
     208: iload         9
     210: iconst_0
     211: iastore
     212: iinc          6, 1
     215: goto          195
     218: aload         8
     220: astore        5
     222: new           #45                 // class java/util/LinkedHashSet
     225: dup
     226: invokespecial #48                 // Method java/util/LinkedHashSet."<init>":()V
     229: checkcast     #50                 // class java/util/Set
     232: astore        6
     234: iconst_1
     235: istore        7
     237: iconst_0
     238: istore        8
     240: aload_0
     241: checkcast     #52                 // class java/util/Collection
     244: invokeinterface #53,  1           // InterfaceMethod java/util/Collection.size:()I
     249: istore        9
     251: iload         8
     253: iload         9
     255: if_icmpge     542
     258: iconst_0
     259: istore        10
     261: aload_3
     262: iload         8
     264: invokeinterface #57,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     269: checkcast     #59                 // class java/lang/Iterable
     272: invokestatic  #65                 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     275: astore        11
     277: aload_3
     278: iload         8
     280: iconst_1
     281: iadd
     282: aload         11
     284: invokeinterface #69,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     289: pop
     290: iload         8
     292: istore        12
     294: iconst_m1
     295: iload         12
     297: if_icmpge     503
     300: aload_0
     301: iload         12
     303: invokeinterface #57,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     308: checkcast     #71                 // class java/lang/Number
     311: invokevirtual #74                 // Method java/lang/Number.intValue:()I
     314: istore        13
     316: aload_1
     317: iload         13
     319: iload         8
     321: iastore
     322: iload         13
     324: iload         10
     326: if_icmpne     497
     329: aload_1
     330: iload         10
     332: iaload
     333: iload         8
     335: if_icmpne     344
     338: iinc          10, 1
     341: goto          329
     344: aload         4
     346: iload         12
     348: iaload
     349: iload         10
     351: istore        16
     353: istore        19
     355: iconst_0
     356: istore        17
     358: iconst_1
     359: iload         16
     361: invokestatic  #78                 // Method countSignificantBits:(I)I
     364: ishl
     365: iconst_1
     366: isub
     367: istore        20
     369: iload         19
     371: iload         20
     373: nop
     374: ior
     375: istore        14
     377: iload         7
     379: iload         14
     381: if_icmpgt     497
     384: aload         5
     386: iload         12
     388: iaload
     389: i2l
     390: bipush        32
     392: lshl
     393: iload         10
     395: i2l
     396: lor
     397: lstore        15
     399: aload         6
     401: lload         15
     403: invokestatic  #83                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     406: invokeinterface #84,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     411: ifeq          497
     414: aload_3
     415: iload         12
     417: invokeinterface #57,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     422: checkcast     #50                 // class java/util/Set
     425: invokeinterface #88,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     430: astore        17
     432: aload         17
     434: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     439: ifeq          476
     442: aload         17
     444: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     449: checkcast     #71                 // class java/lang/Number
     452: invokevirtual #74                 // Method java/lang/Number.intValue:()I
     455: istore        18
     457: aload         11
     459: iload         18
     461: iload         10
     463: ixor
     464: invokestatic  #27                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     467: invokeinterface #84,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     472: pop
     473: goto          432
     476: aload         11
     478: iload         7
     480: invokestatic  #27                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     483: invokeinterface #101,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     488: ifeq          497
     491: iinc          7, 1
     494: goto          476
     497: iinc          12, -1
     500: goto          294
     503: aload         4
     505: iload         8
     507: iconst_1
     508: iadd
     509: aload         11
     511: checkcast     #59                 // class java/lang/Iterable
     514: invokestatic  #105                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     517: checkcast     #71                 // class java/lang/Number
     520: invokevirtual #74                 // Method java/lang/Number.intValue:()I
     523: iastore
     524: aload         5
     526: iload         8
     528: iconst_1
     529: iadd
     530: aload         11
     532: invokevirtual #108                // Method java/lang/Object.hashCode:()I
     535: iastore
     536: iinc          8, 1
     539: goto          251
     542: aload         4
     544: invokestatic  #114                // Method kotlin/collections/ArraysKt.last:([I)I
     547: ireturn

  public static final void main();
    Code:
       0: invokestatic  #145                // 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  #147                // Method solve:()I
      18: istore        4
      20: getstatic     #153                // Field java/lang/System.out:Ljava/io/PrintStream;
      23: iload         4
      25: invokevirtual #158                // Method java/io/PrintStream.println:(I)V
      28: nop
      29: iinc          1, 1
      32: goto          6
      35: return

  private static final int readInt();
    Code:
       0: invokestatic  #12                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: invokestatic  #163                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #12                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: checkcast     #167                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #169                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #171                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #177                // 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  #180                // Method readStrings:()Ljava/util/List;
       3: checkcast     #59                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #35                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #184                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #39                 // 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 #185,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #169                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #163                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #27                 // 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     #18                 // class java/util/List
      96: nop
      97: areturn

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

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


package codeforces.codeton6

val toBaseArray = LongArray(Long.SIZE_BITS)

private fun solve(): Long {
	val (n, k) = readLongs()

	val threshold = (n + 1) / k
	fun timesK(m: Long) = if (m <= threshold) m * k else n + 1

	fun toBase(m: Long): Int {
		var i = 0
		var mm = m
		do {
			toBaseArray[i++] = mm % k
			mm /= k
		} while (mm > 0)
		return i
	}
	val nLength = toBase(n)

	fun lex(m: Long): Long {
		val mLength = toBase(m)
		var res = mLength.toLong()
		var prefix = 0L
		var ten = 1L
		for (i in 0 until nLength) {
			prefix = timesK(prefix) + toBaseArray.getOrElse(mLength - 1 - i) { 0 }
			res += prefix - ten
			ten *= k
		}
		return res
	}

	var ans = 0L
	var ten = 1L
	repeat(nLength) {
		val searchHigh = timesK(ten)
		val high = (ten - 1..searchHigh).binarySearch { lex(it) > it }
		val low = (ten - 1..high).binarySearch { lex(it) >= it }
		ans += high - low
		ten = searchHigh
	}
	return ans
}

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

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

private fun readInt() = readln().toInt()
private fun readStrings() = readln().split(" ")
private fun readLongs() = readStrings().map { it.toLong() }

Compiled from "f.kt"
public final class codeforces.codeton6.FKt {
  private static final long[] toBaseArray;

  public static final long[] getToBaseArray();
    Code:
       0: getstatic     #11                 // Field toBaseArray:[J
       3: areturn

  private static final long solve();
    Code:
       0: invokestatic  #17                 // Method readLongs:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #23,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #25                 // class java/lang/Number
      14: invokevirtual #28                 // Method java/lang/Number.longValue:()J
      17: lstore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #23,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #25                 // class java/lang/Number
      28: invokevirtual #28                 // Method java/lang/Number.longValue:()J
      31: lstore_3
      32: lload_1
      33: lconst_1
      34: ladd
      35: lload_3
      36: ldiv
      37: lstore        5
      39: lload_3
      40: lload_1
      41: invokestatic  #32                 // Method solve$toBase:(JJ)I
      44: istore        7
      46: lconst_0
      47: lstore        17
      49: lconst_0
      50: lstore        19
      52: lconst_1
      53: lstore        19
      55: iconst_0
      56: istore        8
      58: iload         8
      60: iload         7
      62: if_icmpge     162
      65: iload         8
      67: istore        9
      69: iconst_0
      70: istore        10
      72: lload         5
      74: lload_3
      75: lload_1
      76: lload         19
      78: invokestatic  #36                 // Method solve$timesK:(JJJJ)J
      81: lstore        11
      83: new           #38                 // class kotlin/ranges/LongRange
      86: dup
      87: lload         19
      89: lconst_1
      90: lsub
      91: lload         11
      93: invokespecial #42                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
      96: iload         7
      98: lload_3
      99: lload         5
     101: lload_1
     102: invokedynamic #62,  0             // InvokeDynamic #0:invoke:(IJJJ)Lkotlin/jvm/functions/Function1;
     107: invokestatic  #66                 // Method binarySearch:(Lkotlin/ranges/LongRange;Lkotlin/jvm/functions/Function1;)J
     110: lstore        13
     112: new           #38                 // class kotlin/ranges/LongRange
     115: dup
     116: lload         19
     118: lconst_1
     119: lsub
     120: lload         13
     122: invokespecial #42                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
     125: iload         7
     127: lload_3
     128: lload         5
     130: lload_1
     131: invokedynamic #71,  0             // InvokeDynamic #1:invoke:(IJJJ)Lkotlin/jvm/functions/Function1;
     136: invokestatic  #66                 // Method binarySearch:(Lkotlin/ranges/LongRange;Lkotlin/jvm/functions/Function1;)J
     139: lstore        15
     141: lload         17
     143: lload         13
     145: lload         15
     147: lsub
     148: ladd
     149: lstore        17
     151: lload         11
     153: lstore        19
     155: nop
     156: iinc          8, 1
     159: goto          58
     162: lload         17
     164: lreturn

  public static final void main();
    Code:
       0: invokestatic  #90                 // 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  #92                 // Method solve:()J
      18: lstore        4
      20: getstatic     #98                 // Field java/lang/System.out:Ljava/io/PrintStream;
      23: lload         4
      25: invokevirtual #104                // Method java/io/PrintStream.println:(J)V
      28: nop
      29: iinc          1, 1
      32: goto          6
      35: return

  private static final long binarySearch(kotlin.ranges.LongRange, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Boolean>);
    Code:
       0: aload_0
       1: invokevirtual #109                // Method kotlin/ranges/LongRange.getFirst:()J
       4: invokestatic  #115                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       7: aload_0
       8: invokevirtual #118                // Method kotlin/ranges/LongRange.getLast:()J
      11: invokestatic  #115                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      14: invokestatic  #124                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      17: astore_2
      18: lconst_0
      19: lstore        8
      21: aload_2
      22: invokevirtual #130                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      25: checkcast     #25                 // class java/lang/Number
      28: invokevirtual #28                 // Method java/lang/Number.longValue:()J
      31: lstore        8
      33: lconst_0
      34: lstore        10
      36: aload_2
      37: invokevirtual #133                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      40: checkcast     #25                 // class java/lang/Number
      43: invokevirtual #28                 // Method java/lang/Number.longValue:()J
      46: lstore        10
      48: lload         8
      50: lconst_1
      51: ladd
      52: lload         10
      54: lcmp
      55: ifge          112
      58: lload         8
      60: lload         10
      62: lload         8
      64: lsub
      65: iconst_2
      66: i2l
      67: ldiv
      68: ladd
      69: lstore_3
      70: lload_3
      71: lstore        5
      73: iconst_0
      74: istore        7
      76: aload_1
      77: lload         5
      79: invokestatic  #115                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      82: invokeinterface #137,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      87: checkcast     #139                // class java/lang/Boolean
      90: invokevirtual #143                // Method java/lang/Boolean.booleanValue:()Z
      93: ifeq          103
      96: lload         5
      98: lstore        10
     100: goto          107
     103: lload         5
     105: lstore        8
     107: lload_3
     108: pop2
     109: goto          48
     112: lload         10
     114: lreturn

  private static final int readInt();
    Code:
       0: invokestatic  #154                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: invokestatic  #160                // 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 kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: checkcast     #164                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #166                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #168                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #174                // 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.Long> readLongs();
    Code:
       0: invokestatic  #177                // Method readStrings:()Ljava/util/List;
       3: checkcast     #179                // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #181                // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #187                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #190                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #192                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #196,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #201,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #204,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #166                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #208                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      76: nop
      77: invokestatic  #115                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      80: aload         9
      82: swap
      83: invokeinterface #212,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #19                 // class java/util/List
      96: nop
      97: areturn

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

  private static final long solve$timesK(long, long, long, long);
    Code:
       0: lload         6
       2: lload_0
       3: lcmp
       4: ifgt          14
       7: lload         6
       9: lload_2
      10: lmul
      11: goto          18
      14: lload         4
      16: lconst_1
      17: ladd
      18: lreturn

  private static final int solve$toBase(long, long);
    Code:
       0: iconst_0
       1: istore        4
       3: lload_2
       4: lstore        5
       6: getstatic     #11                 // Field toBaseArray:[J
       9: iload         4
      11: iinc          4, 1
      14: lload         5
      16: lload_0
      17: lrem
      18: lastore
      19: lload         5
      21: lload_0
      22: ldiv
      23: lstore        5
      25: lload         5
      27: lconst_0
      28: lcmp
      29: ifgt          6
      32: iload         4
      34: ireturn

  private static final long solve$lex(int, long, long, long, long);
    Code:
       0: lload_1
       1: lload         7
       3: invokestatic  #32                 // Method solve$toBase:(JJ)I
       6: istore        9
       8: iload         9
      10: i2l
      11: lstore        10
      13: lconst_0
      14: lstore        12
      16: lconst_1
      17: lstore        14
      19: iconst_0
      20: istore        16
      22: iload         16
      24: iload_0
      25: if_icmpge     127
      28: lload_3
      29: lload_1
      30: lload         5
      32: lload         12
      34: invokestatic  #36                 // Method solve$timesK:(JJJJ)J
      37: getstatic     #11                 // Field toBaseArray:[J
      40: astore        17
      42: iload         9
      44: iconst_1
      45: isub
      46: iload         16
      48: isub
      49: istore        18
      51: iconst_0
      52: iload         18
      54: if_icmpgt     73
      57: iload         18
      59: aload         17
      61: arraylength
      62: if_icmpge     69
      65: iconst_1
      66: goto          74
      69: iconst_0
      70: goto          74
      73: iconst_0
      74: ifeq          85
      77: aload         17
      79: iload         18
      81: laload
      82: goto          102
      85: iload         18
      87: istore        19
      89: lstore        21
      91: iconst_0
      92: istore        20
      94: lconst_0
      95: lstore        23
      97: lload         21
      99: lload         23
     101: nop
     102: ladd
     103: lstore        12
     105: lload         10
     107: lload         12
     109: lload         14
     111: lsub
     112: ladd
     113: lstore        10
     115: lload         14
     117: lload_1
     118: lmul
     119: lstore        14
     121: iinc          16, 1
     124: goto          22
     127: lload         10
     129: lreturn

  private static final boolean solve$lambda$3$lambda$1(int, long, long, long, long);
    Code:
       0: iload_0
       1: lload_1
       2: lload_3
       3: lload         5
       5: lload         7
       7: invokestatic  #240                // Method solve$lex:(IJJJJ)J
      10: lload         7
      12: lcmp
      13: ifle          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private static final boolean solve$lambda$3$lambda$2(int, long, long, long, long);
    Code:
       0: iload_0
       1: lload_1
       2: lload_3
       3: lload         5
       5: lload         7
       7: invokestatic  #240                // Method solve$lex:(IJJJJ)J
      10: lload         7
      12: lcmp
      13: iflt          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  static {};
    Code:
       0: bipush        64
       2: newarray       long
       4: putstatic     #11                 // Field toBaseArray:[J
       7: return
}


package codeforces.round626

fun main() {
	readLn()
	var a = readInts().sorted()
	val powers = a.last().toString(2).length downTo 0
	val ans = powers.sumBy { k ->
		val two = 1 shl k
		val res = (1..4).sumBy { countLess(a, it * two) } and 1
		a = a.map { it and two - 1 }.sorted()
		two * res
	}
	println(ans)
}

private fun countLess(a: List<Int>, value: Int): Int {
	var j = a.lastIndex
	return a.indices.sumBy { i ->
		while (j >= 0 && a[i] + a[j] >= value) j--
		minOf(i, j + 1)
	}
}

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

Compiled from "b.kt"
public final class codeforces.round626.BKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: pop
       4: new           #12                 // class kotlin/jvm/internal/Ref$ObjectRef
       7: dup
       8: invokespecial #15                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      11: astore_0
      12: aload_0
      13: invokestatic  #19                 // Method readInts:()Ljava/util/List;
      16: checkcast     #21                 // class java/lang/Iterable
      19: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      22: putfield      #31                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      25: aload_0
      26: getfield      #31                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      29: checkcast     #33                 // class java/util/List
      32: invokestatic  #37                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      35: checkcast     #39                 // class java/lang/Number
      38: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      41: iconst_2
      42: invokestatic  #49                 // Method kotlin/text/CharsKt.checkRadix:(I)I
      45: invokestatic  #55                 // Method java/lang/Integer.toString:(II)Ljava/lang/String;
      48: dup
      49: ldc           #57                 // String toString(...)
      51: invokestatic  #63                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      54: invokevirtual #68                 // Method java/lang/String.length:()I
      57: iconst_0
      58: invokestatic  #74                 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      61: astore_1
      62: aload_1
      63: checkcast     #21                 // class java/lang/Iterable
      66: astore_3
      67: iconst_0
      68: istore        4
      70: iconst_0
      71: istore        5
      73: aload_3
      74: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      79: astore        6
      81: aload         6
      83: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      88: ifeq          354
      91: aload         6
      93: checkcast     #86                 // class kotlin/collections/IntIterator
      96: invokevirtual #89                 // Method kotlin/collections/IntIterator.nextInt:()I
      99: istore        7
     101: iload         5
     103: iload         7
     105: istore        8
     107: istore        23
     109: iconst_0
     110: istore        9
     112: iconst_1
     113: iload         8
     115: ishl
     116: istore        10
     118: new           #91                 // class kotlin/ranges/IntRange
     121: dup
     122: iconst_1
     123: iconst_4
     124: invokespecial #94                 // Method kotlin/ranges/IntRange."<init>":(II)V
     127: checkcast     #21                 // class java/lang/Iterable
     130: astore        11
     132: iconst_0
     133: istore        12
     135: iconst_0
     136: istore        13
     138: aload         11
     140: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        14
     147: aload         14
     149: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          205
     157: aload         14
     159: checkcast     #86                 // class kotlin/collections/IntIterator
     162: invokevirtual #89                 // Method kotlin/collections/IntIterator.nextInt:()I
     165: istore        15
     167: iload         13
     169: iload         15
     171: istore        16
     173: istore        17
     175: iconst_0
     176: istore        18
     178: aload_0
     179: getfield      #31                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     182: checkcast     #33                 // class java/util/List
     185: iload         16
     187: iload         10
     189: imul
     190: invokestatic  #98                 // Method countLess:(Ljava/util/List;I)I
     193: istore        19
     195: iload         17
     197: iload         19
     199: iadd
     200: istore        13
     202: goto          147
     205: iload         13
     207: iconst_1
     208: iand
     209: istore        20
     211: aload_0
     212: aload_0
     213: getfield      #31                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     216: checkcast     #21                 // class java/lang/Iterable
     219: astore        11
     221: astore        17
     223: iconst_0
     224: istore        12
     226: aload         11
     228: astore        13
     230: new           #100                // class java/util/ArrayList
     233: dup
     234: aload         11
     236: bipush        10
     238: invokestatic  #104                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     241: invokespecial #107                // Method java/util/ArrayList."<init>":(I)V
     244: checkcast     #109                // class java/util/Collection
     247: astore        14
     249: iconst_0
     250: istore        15
     252: aload         13
     254: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     259: astore        16
     261: aload         16
     263: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifeq          319
     271: aload         16
     273: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     278: astore        18
     280: aload         14
     282: aload         18
     284: checkcast     #39                 // class java/lang/Number
     287: invokevirtual #43                 // Method java/lang/Number.intValue:()I
     290: istore        21
     292: astore        19
     294: iconst_0
     295: istore        22
     297: iload         21
     299: iload         10
     301: iconst_1
     302: isub
     303: iand
     304: invokestatic  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     307: aload         19
     309: swap
     310: invokeinterface #121,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     315: pop
     316: goto          261
     319: aload         14
     321: checkcast     #33                 // class java/util/List
     324: nop
     325: aload         17
     327: swap
     328: checkcast     #21                 // class java/lang/Iterable
     331: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     334: putfield      #31                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     337: iload         10
     339: iload         20
     341: imul
     342: istore        24
     344: iload         23
     346: iload         24
     348: iadd
     349: istore        5
     351: goto          81
     354: iload         5
     356: istore_2
     357: getstatic     #127                // Field java/lang/System.out:Ljava/io/PrintStream;
     360: iload_2
     361: invokevirtual #132                // Method java/io/PrintStream.println:(I)V
     364: return

  private static final int countLess(java.util.List<java.lang.Integer>, int);
    Code:
       0: iconst_0
       1: istore_2
       2: aload_0
       3: invokestatic  #164                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
       6: istore_2
       7: aload_0
       8: checkcast     #109                // class java/util/Collection
      11: invokestatic  #168                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      14: checkcast     #21                 // class java/lang/Iterable
      17: astore_3
      18: iconst_0
      19: istore        4
      21: iconst_0
      22: istore        5
      24: aload_3
      25: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      30: astore        6
      32: aload         6
      34: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      39: ifeq          127
      42: aload         6
      44: checkcast     #86                 // class kotlin/collections/IntIterator
      47: invokevirtual #89                 // Method kotlin/collections/IntIterator.nextInt:()I
      50: istore        7
      52: iload         5
      54: iload         7
      56: istore        8
      58: istore        10
      60: iconst_0
      61: istore        9
      63: iload_2
      64: iflt          106
      67: aload_0
      68: iload         8
      70: invokeinterface #172,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      75: checkcast     #39                 // class java/lang/Number
      78: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      81: aload_0
      82: iload_2
      83: invokeinterface #172,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      88: checkcast     #39                 // class java/lang/Number
      91: invokevirtual #43                 // Method java/lang/Number.intValue:()I
      94: iadd
      95: iload_1
      96: if_icmplt     106
      99: iload_2
     100: iconst_m1
     101: iadd
     102: istore_2
     103: goto          63
     106: iload         8
     108: iload_2
     109: iconst_1
     110: iadd
     111: invokestatic  #178                // Method java/lang/Math.min:(II)I
     114: nop
     115: istore        11
     117: iload         10
     119: iload         11
     121: iadd
     122: istore        5
     124: goto          32
     127: iload         5
     129: ireturn

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #188                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #192                // 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     #196                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #65                 // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #198                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #204                // 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  #207                // Method readStrings:()Ljava/util/List;
       3: checkcast     #21                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #100                // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #104                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #107                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #109                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #65                 // 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  #117                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #121,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #33                 // class java/util/List
      96: nop
      97: areturn

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


package codeforces.round626

import java.io.*

private fun solve(): Long {
	val (n, m) = readInts()
	val c = readLongs()
	val nei = List(n) { mutableListOf<Int>() }
	repeat(m) {
		val (u, v) = readInts().map { it - 1 }
		nei[v].add(u)
	}
	val hashed = nei.map { it.sorted().fold(1L) { acc: Long, x: Int -> acc * 566239L + x } }
	val groups = hashed.indices.groupBy { hashed[it] }.map {
		if (it.key == 1L) 0L else it.value.map { i -> c[i] }.sum()
	}
	return groups.fold(0L, ::gcd)
}

private tailrec fun gcd(a: Long, b: Long): Long = if (a == 0L) b else gcd(b % a, a)

fun main() = println(List(readInt()) { if (it > 0) readLn(); solve() }.joinToString("\n"))

private val `in` = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = `in`.readLine()
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

Compiled from "c.kt"
public final class codeforces.round626.CKt {
  private static final java.io.BufferedReader in;

  private static final long solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: invokestatic  #25                 // Method readLongs:()Ljava/util/List;
      35: astore_3
      36: new           #27                 // class java/util/ArrayList
      39: dup
      40: iload_1
      41: invokespecial #31                 // Method java/util/ArrayList."<init>":(I)V
      44: astore        5
      46: iconst_0
      47: istore        6
      49: iload         6
      51: iload_1
      52: if_icmpge     94
      55: iload         6
      57: istore        7
      59: aload         5
      61: iload         7
      63: istore        8
      65: astore        30
      67: iconst_0
      68: istore        10
      70: new           #27                 // class java/util/ArrayList
      73: dup
      74: invokespecial #34                 // Method java/util/ArrayList."<init>":()V
      77: checkcast     #12                 // class java/util/List
      80: nop
      81: aload         30
      83: swap
      84: invokevirtual #38                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      87: pop
      88: iinc          6, 1
      91: goto          49
      94: aload         5
      96: checkcast     #12                 // class java/util/List
      99: astore        4
     101: iconst_0
     102: istore        5
     104: iload         5
     106: iload_2
     107: if_icmpge     288
     110: iload         5
     112: istore        6
     114: iconst_0
     115: istore        7
     117: invokestatic  #10                 // Method readInts:()Ljava/util/List;
     120: checkcast     #40                 // class java/lang/Iterable
     123: astore        8
     125: iconst_0
     126: istore        10
     128: aload         8
     130: astore        11
     132: new           #27                 // class java/util/ArrayList
     135: dup
     136: aload         8
     138: bipush        10
     140: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     143: invokespecial #31                 // Method java/util/ArrayList."<init>":(I)V
     146: checkcast     #48                 // class java/util/Collection
     149: astore        13
     151: iconst_0
     152: istore        14
     154: aload         11
     156: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     161: astore        15
     163: aload         15
     165: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     170: ifeq          218
     173: aload         15
     175: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     180: astore        16
     182: aload         13
     184: aload         16
     186: checkcast     #18                 // class java/lang/Number
     189: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     192: istore        17
     194: astore        18
     196: iconst_0
     197: istore        20
     199: iload         17
     201: iconst_1
     202: isub
     203: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     206: aload         18
     208: swap
     209: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     214: pop
     215: goto          163
     218: aload         13
     220: checkcast     #12                 // class java/util/List
     223: nop
     224: astore        21
     226: aload         21
     228: iconst_0
     229: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     234: checkcast     #18                 // class java/lang/Number
     237: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     240: istore        8
     242: aload         21
     244: iconst_1
     245: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     250: checkcast     #18                 // class java/lang/Number
     253: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     256: istore        10
     258: aload         4
     260: iload         10
     262: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     267: checkcast     #12                 // class java/util/List
     270: iload         8
     272: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     275: invokeinterface #70,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     280: pop
     281: nop
     282: iinc          5, 1
     285: goto          104
     288: aload         4
     290: checkcast     #40                 // class java/lang/Iterable
     293: astore        6
     295: iconst_0
     296: istore        7
     298: aload         6
     300: astore        8
     302: new           #27                 // class java/util/ArrayList
     305: dup
     306: aload         6
     308: bipush        10
     310: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     313: invokespecial #31                 // Method java/util/ArrayList."<init>":(I)V
     316: checkcast     #48                 // class java/util/Collection
     319: astore        10
     321: iconst_0
     322: istore        11
     324: aload         8
     326: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     331: astore        13
     333: aload         13
     335: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     340: ifeq          467
     343: aload         13
     345: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     350: astore        14
     352: aload         10
     354: aload         14
     356: checkcast     #12                 // class java/util/List
     359: astore        15
     361: astore        30
     363: iconst_0
     364: istore        16
     366: aload         15
     368: checkcast     #40                 // class java/lang/Iterable
     371: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     374: checkcast     #40                 // class java/lang/Iterable
     377: astore        17
     379: lconst_1
     380: lstore        18
     382: iconst_0
     383: istore        20
     385: lload         18
     387: lstore        21
     389: aload         17
     391: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     396: astore        23
     398: aload         23
     400: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     405: ifeq          449
     408: aload         23
     410: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     415: astore        24
     417: lload         21
     419: aload         24
     421: checkcast     #18                 // class java/lang/Number
     424: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     427: istore        25
     429: lstore        26
     431: iconst_0
     432: istore        28
     434: lload         26
     436: ldc2_w        #75                 // long 566239l
     439: lmul
     440: iload         25
     442: i2l
     443: ladd
     444: lstore        21
     446: goto          398
     449: lload         21
     451: nop
     452: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     455: aload         30
     457: swap
     458: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     463: pop
     464: goto          333
     467: aload         10
     469: checkcast     #12                 // class java/util/List
     472: nop
     473: astore        5
     475: aload         5
     477: checkcast     #48                 // class java/util/Collection
     480: invokestatic  #85                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     483: checkcast     #40                 // class java/lang/Iterable
     486: astore        7
     488: iconst_0
     489: istore        8
     491: aload         7
     493: astore        10
     495: new           #87                 // class java/util/LinkedHashMap
     498: dup
     499: invokespecial #88                 // Method java/util/LinkedHashMap."<init>":()V
     502: checkcast     #90                 // class java/util/Map
     505: astore        11
     507: iconst_0
     508: istore        13
     510: aload         10
     512: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     517: astore        14
     519: aload         14
     521: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     526: ifeq          647
     529: aload         14
     531: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     536: astore        15
     538: aload         15
     540: checkcast     #18                 // class java/lang/Number
     543: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     546: istore        16
     548: iconst_0
     549: istore        17
     551: aload         5
     553: iload         16
     555: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     560: checkcast     #18                 // class java/lang/Number
     563: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     566: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     569: astore        18
     571: aload         11
     573: astore        20
     575: iconst_0
     576: istore        21
     578: aload         20
     580: aload         18
     582: invokeinterface #96,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     587: astore        23
     589: aload         23
     591: ifnonnull     626
     594: iconst_0
     595: istore        24
     597: new           #27                 // class java/util/ArrayList
     600: dup
     601: invokespecial #34                 // Method java/util/ArrayList."<init>":()V
     604: checkcast     #12                 // class java/util/List
     607: astore        24
     609: aload         20
     611: aload         18
     613: aload         24
     615: invokeinterface #100,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     620: pop
     621: aload         24
     623: goto          628
     626: aload         23
     628: nop
     629: checkcast     #12                 // class java/util/List
     632: astore        25
     634: aload         25
     636: aload         15
     638: invokeinterface #70,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     643: pop
     644: goto          519
     647: aload         11
     649: nop
     650: astore        7
     652: nop
     653: iconst_0
     654: istore        8
     656: aload         7
     658: astore        10
     660: new           #27                 // class java/util/ArrayList
     663: dup
     664: aload         7
     666: invokeinterface #103,  1          // InterfaceMethod java/util/Map.size:()I
     671: invokespecial #31                 // Method java/util/ArrayList."<init>":(I)V
     674: checkcast     #48                 // class java/util/Collection
     677: astore        11
     679: iconst_0
     680: istore        13
     682: aload         10
     684: invokeinterface #107,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     689: invokeinterface #110,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     694: astore        14
     696: aload         14
     698: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     703: ifeq          893
     706: aload         14
     708: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     713: checkcast     #112                // class java/util/Map$Entry
     716: astore        15
     718: aload         11
     720: aload         15
     722: astore        16
     724: astore        30
     726: iconst_0
     727: istore        17
     729: aload         16
     731: invokeinterface #115,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     736: checkcast     #18                 // class java/lang/Number
     739: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     742: lconst_1
     743: lcmp
     744: ifne          751
     747: lconst_0
     748: goto          878
     751: aload         16
     753: invokeinterface #118,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     758: checkcast     #40                 // class java/lang/Iterable
     761: astore        18
     763: iconst_0
     764: istore        20
     766: aload         18
     768: astore        21
     770: new           #27                 // class java/util/ArrayList
     773: dup
     774: aload         18
     776: bipush        10
     778: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     781: invokespecial #31                 // Method java/util/ArrayList."<init>":(I)V
     784: checkcast     #48                 // class java/util/Collection
     787: astore        23
     789: iconst_0
     790: istore        24
     792: aload         21
     794: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     799: astore        25
     801: aload         25
     803: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     808: ifeq          866
     811: aload         25
     813: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     818: astore        26
     820: aload         23
     822: aload         26
     824: checkcast     #18                 // class java/lang/Number
     827: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     830: istore        27
     832: astore        28
     834: iconst_0
     835: istore        29
     837: aload_3
     838: iload         27
     840: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     845: checkcast     #18                 // class java/lang/Number
     848: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     851: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     854: aload         28
     856: swap
     857: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     862: pop
     863: goto          801
     866: aload         23
     868: checkcast     #12                 // class java/util/List
     871: nop
     872: checkcast     #40                 // class java/lang/Iterable
     875: invokestatic  #122                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     878: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     881: aload         30
     883: swap
     884: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     889: pop
     890: goto          696
     893: aload         11
     895: checkcast     #12                 // class java/util/List
     898: nop
     899: astore        6
     901: aload         6
     903: checkcast     #40                 // class java/lang/Iterable
     906: astore        7
     908: lconst_0
     909: lstore        8
     911: iconst_0
     912: istore        10
     914: lload         8
     916: lstore        11
     918: aload         7
     920: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     925: astore        13
     927: aload         13
     929: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     934: ifeq          975
     937: aload         13
     939: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     944: astore        14
     946: lload         11
     948: aload         14
     950: checkcast     #18                 // class java/lang/Number
     953: invokevirtual #93                 // Method java/lang/Number.longValue:()J
     956: lstore        15
     958: lstore        17
     960: iconst_0
     961: istore        20
     963: lload         17
     965: lload         15
     967: invokestatic  #126                // Method gcd:(JJ)J
     970: lstore        11
     972: goto          927
     975: lload         11
     977: lreturn

  private static final long gcd(long, long);
    Code:
       0: lload_0
       1: lconst_0
       2: lcmp
       3: ifne          10
       6: lload_2
       7: goto          27
      10: lload_2
      11: lload_0
      12: lrem
      13: lstore        4
      15: lload_0
      16: lstore        6
      18: lload         4
      20: lstore_0
      21: lload         6
      23: lstore_2
      24: goto          0
      27: lreturn

  public static final void main();
    Code:
       0: invokestatic  #186                // Method readInt:()I
       3: istore_0
       4: new           #27                 // class java/util/ArrayList
       7: dup
       8: iload_0
       9: invokespecial #31                 // 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     59
      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: iload         4
      33: ifle          40
      36: invokestatic  #190                // Method readLn:()Ljava/lang/String;
      39: pop
      40: invokestatic  #192                // Method solve:()J
      43: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      46: aload         6
      48: swap
      49: invokevirtual #38                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      52: pop
      53: iinc          2, 1
      56: goto          15
      59: aload_1
      60: checkcast     #12                 // class java/util/List
      63: checkcast     #40                 // class java/lang/Iterable
      66: ldc           #194                // String \n
      68: checkcast     #196                // class java/lang/CharSequence
      71: aconst_null
      72: aconst_null
      73: iconst_0
      74: aconst_null
      75: aconst_null
      76: bipush        62
      78: aconst_null
      79: invokestatic  #200                // 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;
      82: getstatic     #206                // Field java/lang/System.out:Ljava/io/PrintStream;
      85: swap
      86: invokevirtual #212                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      89: return

  private static final java.lang.String readLn();
    Code:
       0: getstatic     #217                // Field in:Ljava/io/BufferedReader;
       3: invokevirtual #222                // Method java/io/BufferedReader.readLine:()Ljava/lang/String;
       6: areturn

  private static final int readInt();
    Code:
       0: invokestatic  #190                // Method readLn:()Ljava/lang/String;
       3: dup
       4: ldc           #224                // String readLn(...)
       6: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
       9: invokestatic  #234                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      12: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #190                // Method readLn:()Ljava/lang/String;
       3: dup
       4: ldc           #224                // String readLn(...)
       6: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
       9: checkcast     #196                // class java/lang/CharSequence
      12: iconst_1
      13: anewarray     #238                // class java/lang/String
      16: astore_0
      17: aload_0
      18: iconst_0
      19: ldc           #240                // String
      21: aastore
      22: aload_0
      23: iconst_0
      24: iconst_0
      25: bipush        6
      27: aconst_null
      28: invokestatic  #246                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      31: areturn

  private static final java.util.List<java.lang.Integer> readInts();
    Code:
       0: invokestatic  #249                // Method readStrings:()Ljava/util/List;
       3: checkcast     #40                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #27                 // 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 #31                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #48                 // 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     #238                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #234                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #69,  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

  private static final java.util.List<java.lang.Long> readLongs();
    Code:
       0: invokestatic  #249                // Method readStrings:()Ljava/util/List;
       3: checkcast     #40                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #27                 // 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 #31                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #48                 // 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     #238                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #256                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      76: nop
      77: invokestatic  #81                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      80: aload         9
      82: swap
      83: invokeinterface #69,  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  #260                // Method main:()V
       3: return

  static {};
    Code:
       0: new           #219                // class java/io/BufferedReader
       3: dup
       4: new           #265                // class java/io/InputStreamReader
       7: dup
       8: getstatic     #268                // Field java/lang/System.in:Ljava/io/InputStream;
      11: invokespecial #271                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      14: checkcast     #273                // class java/io/Reader
      17: invokespecial #276                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
      20: putstatic     #217                // Field in:Ljava/io/BufferedReader;
      23: return
}