package codeforces.globalround20

private fun solve() {
	val n = readInt()
	val a = readInts()
	val count = IntArray(n + 1)
	val pos = List(n + 1) { mutableListOf<Int>() }
	for (i in a.indices) {
		count[a[i]]++
		pos[a[i]].add(i)
	}
	val often = count.indices.sortedBy { count[it] }
	val mostOften = often.last()
	val ans = IntArray(n) { -1 }
	for (i in 0..often.size - 2) {
		val v = often[i]
		val u = often[i + 1]
		for (j in 0 until count[v]) {
			ans[pos[u][j]] = v
		}
	}
	for (i in ans.indices) {
		if (ans[i] == -1) ans[i] = mostOften
	}
	println(ans.joinToString(" "))
}

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

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

Compiled from "Comparisons.kt"
public final class codeforces.globalround20.F1Kt$solve$$inlined$sortedBy$1<T> implements java.util.Comparator {
  final int[] $count$inlined;

  public codeforces.globalround20.F1Kt$solve$$inlined$sortedBy$1(int[]);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $count$inlined:[I
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #28                 // class java/lang/Number
       4: invokevirtual #32                 // Method java/lang/Number.intValue:()I
       7: istore_3
       8: iconst_0
       9: istore        4
      11: aload_0
      12: getfield      #18                 // Field $count$inlined:[I
      15: iload_3
      16: iaload
      17: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: checkcast     #40                 // class java/lang/Comparable
      23: aload_2
      24: checkcast     #28                 // class java/lang/Number
      27: invokevirtual #32                 // Method java/lang/Number.intValue:()I
      30: istore_3
      31: astore        5
      33: iconst_0
      34: istore        4
      36: aload_0
      37: getfield      #18                 // Field $count$inlined:[I
      40: iload_3
      41: iaload
      42: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      45: aload         5
      47: swap
      48: checkcast     #40                 // class java/lang/Comparable
      51: invokestatic  #46                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      54: ireturn
}

Compiled from "f1.kt"
public final class codeforces.globalround20.F1Kt {
  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: invokestatic  #14                 // Method readInts:()Ljava/util/List;
       7: astore_1
       8: iload_0
       9: iconst_1
      10: iadd
      11: newarray       int
      13: astore_2
      14: iload_0
      15: iconst_1
      16: iadd
      17: istore        4
      19: new           #16                 // class java/util/ArrayList
      22: dup
      23: iload         4
      25: invokespecial #20                 // Method java/util/ArrayList."<init>":(I)V
      28: astore        5
      30: iconst_0
      31: istore        6
      33: iload         6
      35: iload         4
      37: if_icmpge     79
      40: iload         6
      42: istore        7
      44: aload         5
      46: iload         7
      48: istore        8
      50: astore        13
      52: iconst_0
      53: istore        9
      55: new           #16                 // class java/util/ArrayList
      58: dup
      59: invokespecial #22                 // Method java/util/ArrayList."<init>":()V
      62: checkcast     #24                 // class java/util/List
      65: nop
      66: aload         13
      68: swap
      69: invokevirtual #28                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      72: pop
      73: iinc          6, 1
      76: goto          33
      79: aload         5
      81: checkcast     #24                 // class java/util/List
      84: astore_3
      85: iconst_0
      86: istore        4
      88: aload_1
      89: checkcast     #30                 // class java/util/Collection
      92: invokeinterface #33,  1           // InterfaceMethod java/util/Collection.size:()I
      97: istore        5
      99: iload         4
     101: iload         5
     103: if_icmpge     176
     106: aload_1
     107: iload         4
     109: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     114: checkcast     #39                 // class java/lang/Number
     117: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     120: istore        6
     122: aload_2
     123: iload         6
     125: iaload
     126: istore        7
     128: aload_2
     129: iload         6
     131: iload         7
     133: iconst_1
     134: iadd
     135: iastore
     136: aload_3
     137: aload_1
     138: iload         4
     140: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: checkcast     #39                 // class java/lang/Number
     148: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     151: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     156: checkcast     #24                 // class java/util/List
     159: iload         4
     161: invokestatic  #48                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     164: invokeinterface #49,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     169: pop
     170: iinc          4, 1
     173: goto          99
     176: aload_2
     177: invokestatic  #55                 // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
     180: checkcast     #57                 // class java/lang/Iterable
     183: astore        5
     185: iconst_0
     186: istore        6
     188: aload         5
     190: new           #59                 // class codeforces/globalround20/F1Kt$solve$$inlined$sortedBy$1
     193: dup
     194: aload_2
     195: invokespecial #62                 // Method codeforces/globalround20/F1Kt$solve$$inlined$sortedBy$1."<init>":([I)V
     198: checkcast     #64                 // class java/util/Comparator
     201: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     204: astore        4
     206: aload         4
     208: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     211: checkcast     #39                 // class java/lang/Number
     214: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     217: istore        5
     219: iconst_0
     220: istore        7
     222: iload_0
     223: newarray       int
     225: astore        8
     227: iload         7
     229: iload_0
     230: if_icmpge     249
     233: iload         7
     235: istore        9
     237: aload         8
     239: iload         9
     241: iconst_m1
     242: iastore
     243: iinc          7, 1
     246: goto          227
     249: aload         8
     251: astore        6
     253: iconst_0
     254: istore        7
     256: aload         4
     258: invokeinterface #75,  1           // InterfaceMethod java/util/List.size:()I
     263: iconst_2
     264: isub
     265: istore        8
     267: iload         7
     269: iload         8
     271: if_icmpgt     374
     274: aload         4
     276: iload         7
     278: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     283: checkcast     #39                 // class java/lang/Number
     286: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     289: istore        9
     291: aload         4
     293: iload         7
     295: iconst_1
     296: iadd
     297: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     302: checkcast     #39                 // class java/lang/Number
     305: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     308: istore        10
     310: iconst_0
     311: istore        11
     313: aload_2
     314: iload         9
     316: iaload
     317: istore        12
     319: iload         11
     321: iload         12
     323: if_icmpge     361
     326: aload         6
     328: aload_3
     329: iload         10
     331: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     336: checkcast     #24                 // class java/util/List
     339: iload         11
     341: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     346: checkcast     #39                 // class java/lang/Number
     349: invokevirtual #42                 // Method java/lang/Number.intValue:()I
     352: iload         9
     354: iastore
     355: iinc          11, 1
     358: goto          319
     361: iload         7
     363: iload         8
     365: if_icmpeq     374
     368: iinc          7, 1
     371: goto          274
     374: iconst_0
     375: istore        7
     377: aload         6
     379: arraylength
     380: istore        8
     382: iload         7
     384: iload         8
     386: if_icmpge     411
     389: aload         6
     391: iload         7
     393: iaload
     394: iconst_m1
     395: if_icmpne     405
     398: aload         6
     400: iload         7
     402: iload         5
     404: iastore
     405: iinc          7, 1
     408: goto          382
     411: aload         6
     413: ldc           #77                 // String
     415: checkcast     #79                 // class java/lang/CharSequence
     418: aconst_null
     419: aconst_null
     420: iconst_0
     421: aconst_null
     422: aconst_null
     423: bipush        62
     425: aconst_null
     426: invokestatic  #83                 // Method kotlin/collections/ArraysKt.joinToString$default:([ILjava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     429: getstatic     #89                 // Field java/lang/System.out:Ljava/io/PrintStream;
     432: swap
     433: invokevirtual #95                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     436: return

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

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

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #133                // Method readLn:()Ljava/lang/String;
       3: checkcast     #79                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #141                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #77                 // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #147                // 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  #150                // Method readStrings:()Ljava/util/List;
       3: checkcast     #57                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #16                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #154                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #20                 // 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 #158,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #141                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #137                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #48                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #169,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #24                 // class java/util/List
      96: nop
      97: areturn

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


package codeforces.globalround7

fun main() {
	val n = readInt()
	val p = readInts().map { it - 1 }
	val q = readInts().map { it - 1 }
	val pRev = IntArray(n)
	for (i in p.indices) pRev[p[i]] = i

	val st = SegmentsTreeSimple(2 * n)
	var alive = n
	val ans = q.map {
		while (st.getMinBalance() >= 0) st[2 * n - 2 * pRev[--alive] - 1] = -1
		st[2 * n - 2 * it - 2] = 1
		alive
	}
	println(ans.map{ it + 1 }.joinToString(" "))
}

class SegmentsTreeSimple(var n: Int) {
	var size = 2 * Integer.highestOneBit(n)
	var min = IntArray(2 * size)
	var sum = IntArray(2 * size)

	operator fun set(index: Int, value: Int) {
		var i = size + index
		min[i] = minOf(0, value)
		sum[i] = value
		while (i > 1) {
			i /= 2
			min[i] = minOf(min[2 * i], sum[2 * i] + min[2 * i + 1])
			sum[i] = sum[2 * i] + sum[2 * i + 1]
		}
	}

	fun getMinBalance(): Int = min[1]
}

private fun readLn() = readLine()!!
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.globalround7.EKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: invokestatic  #14                 // Method readInts:()Ljava/util/List;
       7: checkcast     #16                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #18                 // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #30                 // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          101
      56: aload         7
      58: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #46                 // class java/lang/Number
      72: invokevirtual #49                 // Method java/lang/Number.intValue:()I
      75: istore        9
      77: astore        16
      79: iconst_0
      80: istore        10
      82: iload         9
      84: iconst_1
      85: isub
      86: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: aload         16
      91: swap
      92: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      97: pop
      98: goto          46
     101: aload         5
     103: checkcast     #61                 // class java/util/List
     106: nop
     107: astore_1
     108: invokestatic  #14                 // Method readInts:()Ljava/util/List;
     111: checkcast     #16                 // class java/lang/Iterable
     114: astore_3
     115: iconst_0
     116: istore        4
     118: aload_3
     119: astore        5
     121: new           #18                 // class java/util/ArrayList
     124: dup
     125: aload_3
     126: bipush        10
     128: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     131: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     134: checkcast     #30                 // class java/util/Collection
     137: astore        6
     139: iconst_0
     140: istore        7
     142: aload         5
     144: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     149: astore        8
     151: aload         8
     153: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     158: ifeq          206
     161: aload         8
     163: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     168: astore        9
     170: aload         6
     172: aload         9
     174: checkcast     #46                 // class java/lang/Number
     177: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     180: istore        10
     182: astore        16
     184: iconst_0
     185: istore        11
     187: iload         10
     189: iconst_1
     190: isub
     191: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     194: aload         16
     196: swap
     197: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     202: pop
     203: goto          151
     206: aload         6
     208: checkcast     #61                 // class java/util/List
     211: nop
     212: astore_2
     213: iload_0
     214: newarray       int
     216: astore_3
     217: iconst_0
     218: istore        4
     220: aload_1
     221: checkcast     #30                 // class java/util/Collection
     224: invokeinterface #64,  1           // InterfaceMethod java/util/Collection.size:()I
     229: istore        5
     231: iload         4
     233: iload         5
     235: if_icmpge     262
     238: aload_3
     239: aload_1
     240: iload         4
     242: invokeinterface #68,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     247: checkcast     #46                 // class java/lang/Number
     250: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     253: iload         4
     255: iastore
     256: iinc          4, 1
     259: goto          231
     262: new           #70                 // class codeforces/globalround7/SegmentsTreeSimple
     265: dup
     266: iconst_2
     267: iload_0
     268: imul
     269: invokespecial #71                 // Method codeforces/globalround7/SegmentsTreeSimple."<init>":(I)V
     272: astore        4
     274: iconst_0
     275: istore        5
     277: iload_0
     278: istore        5
     280: aload_2
     281: checkcast     #16                 // class java/lang/Iterable
     284: astore        7
     286: iconst_0
     287: istore        8
     289: aload         7
     291: astore        9
     293: new           #18                 // class java/util/ArrayList
     296: dup
     297: aload         7
     299: bipush        10
     301: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     304: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     307: checkcast     #30                 // class java/util/Collection
     310: astore        10
     312: iconst_0
     313: istore        11
     315: aload         9
     317: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     322: astore        12
     324: aload         12
     326: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          428
     334: aload         12
     336: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     341: astore        13
     343: aload         10
     345: aload         13
     347: checkcast     #46                 // class java/lang/Number
     350: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     353: istore        14
     355: astore        16
     357: iconst_0
     358: istore        15
     360: aload         4
     362: invokevirtual #74                 // Method codeforces/globalround7/SegmentsTreeSimple.getMinBalance:()I
     365: iflt          395
     368: aload         4
     370: iconst_2
     371: iload_0
     372: imul
     373: iconst_2
     374: aload_3
     375: iload         5
     377: iconst_m1
     378: iadd
     379: istore        5
     381: iload         5
     383: iaload
     384: imul
     385: isub
     386: iconst_1
     387: isub
     388: iconst_m1
     389: invokevirtual #78                 // Method codeforces/globalround7/SegmentsTreeSimple.set:(II)V
     392: goto          360
     395: aload         4
     397: iconst_2
     398: iload_0
     399: imul
     400: iconst_2
     401: iload         14
     403: imul
     404: isub
     405: iconst_2
     406: isub
     407: iconst_1
     408: invokevirtual #78                 // Method codeforces/globalround7/SegmentsTreeSimple.set:(II)V
     411: iload         5
     413: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     416: aload         16
     418: swap
     419: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     424: pop
     425: goto          324
     428: aload         10
     430: checkcast     #61                 // class java/util/List
     433: nop
     434: astore        6
     436: aload         6
     438: checkcast     #16                 // class java/lang/Iterable
     441: astore        7
     443: iconst_0
     444: istore        8
     446: aload         7
     448: astore        9
     450: new           #18                 // class java/util/ArrayList
     453: dup
     454: aload         7
     456: bipush        10
     458: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     461: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     464: checkcast     #30                 // class java/util/Collection
     467: astore        10
     469: iconst_0
     470: istore        11
     472: aload         9
     474: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     479: astore        12
     481: aload         12
     483: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     488: ifeq          536
     491: aload         12
     493: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     498: astore        13
     500: aload         10
     502: aload         13
     504: checkcast     #46                 // class java/lang/Number
     507: invokevirtual #49                 // Method java/lang/Number.intValue:()I
     510: istore        14
     512: astore        16
     514: iconst_0
     515: istore        15
     517: iload         14
     519: iconst_1
     520: iadd
     521: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     524: aload         16
     526: swap
     527: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     532: pop
     533: goto          481
     536: aload         10
     538: checkcast     #61                 // class java/util/List
     541: nop
     542: checkcast     #16                 // class java/lang/Iterable
     545: ldc           #80                 // String
     547: checkcast     #82                 // class java/lang/CharSequence
     550: aconst_null
     551: aconst_null
     552: iconst_0
     553: aconst_null
     554: aconst_null
     555: bipush        62
     557: aconst_null
     558: invokestatic  #86                 // 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;
     561: getstatic     #92                 // Field java/lang/System.out:Ljava/io/PrintStream;
     564: swap
     565: invokevirtual #98                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     568: return

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

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

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #139                // Method readLn:()Ljava/lang/String;
       3: checkcast     #82                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #147                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #80                 // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #153                // 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  #156                // 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     #147                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #143                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #55                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #59,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          39
      92: aload_3
      93: checkcast     #61                 // class java/util/List
      96: nop
      97: areturn

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


package codeforces.globalround7

private fun solve() {
	val s = readLn()
	var i = 0
	while (i < s.length - 1 - i && s[i] == s[s.length - 1 - i]) i++
	println(s.take(i) + solve(s.drop(i).dropLast(i)) + s.takeLast(i))
}

private fun solve(s: String): String {
	val n = s.length
	val h = Hashing(s + s.reversed())
	for (i in n downTo 0) {
		if (h.hash(0, i) == h.hash(2 * n - i, 2 * n)) return s.take(i)
		if (h.hash(n - i, n) == h.hash(n, n + i)) return s.takeLast(i)
	}
	error(s)
}

private const val M = 1_000_000_007

class Hashing(s: String, x: Int = 566239) {
	val h = IntArray(s.length + 1)
	val t = IntArray(s.length + 1)

	fun hash(from: Int, to: Int): Int {
		var res = ((h[to] - h[from] * t[to - from].toLong()) % M).toInt()
		if (res < 0) res += M
		return res
	}

	init {
		t[0] = 1
		for (i in s.indices) {
			t[i + 1] = (t[i] * x.toLong() % M).toInt()
			h[i + 1] = ((h[i] * x.toLong() + s[i].toLong()) % M).toInt()
		}
	}
}

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

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

Compiled from "d.kt"
public final class codeforces.globalround7.DKt {
  private static final int M;

  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: astore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: aload_0
       8: invokevirtual #16                 // Method java/lang/String.length:()I
      11: iconst_1
      12: isub
      13: iload_1
      14: isub
      15: if_icmpge     44
      18: aload_0
      19: iload_1
      20: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
      23: aload_0
      24: aload_0
      25: invokevirtual #16                 // Method java/lang/String.length:()I
      28: iconst_1
      29: isub
      30: iload_1
      31: isub
      32: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
      35: if_icmpne     44
      38: iinc          1, 1
      41: goto          6
      44: new           #22                 // class java/lang/StringBuilder
      47: dup
      48: invokespecial #25                 // Method java/lang/StringBuilder."<init>":()V
      51: aload_0
      52: iload_1
      53: invokestatic  #31                 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;
      56: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      59: aload_0
      60: iload_1
      61: invokestatic  #38                 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;
      64: iload_1
      65: invokestatic  #41                 // Method kotlin/text/StringsKt.dropLast:(Ljava/lang/String;I)Ljava/lang/String;
      68: invokestatic  #44                 // Method solve:(Ljava/lang/String;)Ljava/lang/String;
      71: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      74: aload_0
      75: iload_1
      76: invokestatic  #47                 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
      79: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      82: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      85: getstatic     #56                 // Field java/lang/System.out:Ljava/io/PrintStream;
      88: swap
      89: invokevirtual #62                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      92: return

  private static final java.lang.String solve(java.lang.String);
    Code:
       0: aload_0
       1: invokevirtual #16                 // Method java/lang/String.length:()I
       4: istore_1
       5: new           #68                 // class codeforces/globalround7/Hashing
       8: dup
       9: new           #22                 // class java/lang/StringBuilder
      12: dup
      13: invokespecial #25                 // Method java/lang/StringBuilder."<init>":()V
      16: aload_0
      17: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: aload_0
      21: checkcast     #70                 // class java/lang/CharSequence
      24: invokestatic  #74                 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      27: invokevirtual #75                 // Method java/lang/Object.toString:()Ljava/lang/String;
      30: invokevirtual #35                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      33: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      36: iconst_0
      37: iconst_2
      38: aconst_null
      39: invokespecial #78                 // Method codeforces/globalround7/Hashing."<init>":(Ljava/lang/String;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
      42: astore_2
      43: iload_1
      44: istore_3
      45: iconst_m1
      46: iload_3
      47: if_icmpge     108
      50: aload_2
      51: iconst_0
      52: iload_3
      53: invokevirtual #82                 // Method codeforces/globalround7/Hashing.hash:(II)I
      56: aload_2
      57: iconst_2
      58: iload_1
      59: imul
      60: iload_3
      61: isub
      62: iconst_2
      63: iload_1
      64: imul
      65: invokevirtual #82                 // Method codeforces/globalround7/Hashing.hash:(II)I
      68: if_icmpne     77
      71: aload_0
      72: iload_3
      73: invokestatic  #31                 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;
      76: areturn
      77: aload_2
      78: iload_1
      79: iload_3
      80: isub
      81: iload_1
      82: invokevirtual #82                 // Method codeforces/globalround7/Hashing.hash:(II)I
      85: aload_2
      86: iload_1
      87: iload_1
      88: iload_3
      89: iadd
      90: invokevirtual #82                 // Method codeforces/globalround7/Hashing.hash:(II)I
      93: if_icmpne     102
      96: aload_0
      97: iload_3
      98: invokestatic  #47                 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
     101: areturn
     102: iinc          3, -1
     105: goto          45
     108: new           #84                 // class java/lang/IllegalStateException
     111: dup
     112: aload_0
     113: invokevirtual #75                 // Method java/lang/Object.toString:()Ljava/lang/String;
     116: invokespecial #87                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     119: athrow

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

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

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

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


package codeforces.round621

const val M = 1_000_000_007

fun main() {
	val (n, m) = readInts()
	val a = readInts().map { it - 1 }
	val indices = List(n) { mutableListOf<Int>() }
	for (x in a.indices) { indices[a[x]].add(x) }
	val eaters = List(n) { mutableSetOf<Int>() }
	repeat(m) {
		val (id, hunger) = readInts().map { it - 1 }
		eaters[id].add(hunger)
	}
	val eatable = List(2) { BooleanArray(n) { false } }
	val count = List(2) { IntArray(n) { 0 } }
	for (id in eaters.indices) {
		for (hunger in eaters[id]) {
			if (hunger < indices[id].size) {
				eatable[0][indices[id][hunger]] = true
				eatable[1][indices[id][indices[id].size - 1 - hunger]] = true
				count[1][id]++
 			}
		}
	}
	var max = 0
	var waysMax = 1
	for (v in count[1].filter { it > 0 }) {
		max++
		waysMax = ((waysMax.toLong() * v) % M).toInt()
	}
	for (x in a.indices) {
		if (eatable[1][x]) count[1][a[x]]--
		if (eatable[0][x]) count[0][a[x]]++ else continue
		var cur = 0
		var ways = 1
		for (id in a.indices) {
			val left = count[0][id]
			val right = count[1][id]
			val (two, one) = if (id == a[x]) {
				(if (left - 1 < right) right - 1 else right) to 1
			} else {
				left * right - minOf(left, right) to left + right
			}
			val mul = if (two > 0) { cur += 2; two } else if (one > 0) { cur++; one } else continue
			ways = ((ways.toLong() * mul) % M).toInt()
		}
		if (cur > max) {
			max = cur; waysMax = ways
		} else if (cur == max) {
			waysMax = (waysMax + ways) % M
		}
	}
	println("$max $waysMax")
}

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

Compiled from "e.kt"
public final class codeforces.round621.EKt {
  public static final int M;

  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      35: checkcast     #24                 // class java/lang/Iterable
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload         4
      45: astore        6
      47: new           #26                 // class java/util/ArrayList
      50: dup
      51: aload         4
      53: bipush        10
      55: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      58: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      61: checkcast     #38                 // class java/util/Collection
      64: astore        7
      66: iconst_0
      67: istore        8
      69: aload         6
      71: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      76: astore        9
      78: aload         9
      80: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      85: ifeq          133
      88: aload         9
      90: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      95: astore        10
      97: aload         7
      99: aload         10
     101: checkcast     #18                 // class java/lang/Number
     104: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     107: istore        11
     109: astore        22
     111: iconst_0
     112: istore        12
     114: iload         11
     116: iconst_1
     117: isub
     118: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: aload         22
     123: swap
     124: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          78
     133: aload         7
     135: checkcast     #12                 // class java/util/List
     138: nop
     139: astore_3
     140: new           #26                 // class java/util/ArrayList
     143: dup
     144: iload_1
     145: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     148: astore        5
     150: iconst_0
     151: istore        6
     153: iload         6
     155: iload_1
     156: if_icmpge     198
     159: iload         6
     161: istore        7
     163: aload         5
     165: iload         7
     167: istore        8
     169: astore        22
     171: iconst_0
     172: istore        9
     174: new           #26                 // class java/util/ArrayList
     177: dup
     178: invokespecial #64                 // Method java/util/ArrayList."<init>":()V
     181: checkcast     #12                 // class java/util/List
     184: nop
     185: aload         22
     187: swap
     188: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     191: pop
     192: iinc          6, 1
     195: goto          153
     198: aload         5
     200: checkcast     #12                 // class java/util/List
     203: astore        4
     205: iconst_0
     206: istore        5
     208: aload_3
     209: checkcast     #38                 // class java/util/Collection
     212: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
     217: istore        6
     219: iload         5
     221: iload         6
     223: if_icmpge     267
     226: aload         4
     228: aload_3
     229: iload         5
     231: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     236: checkcast     #18                 // class java/lang/Number
     239: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     242: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     247: checkcast     #12                 // class java/util/List
     250: iload         5
     252: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     255: invokeinterface #69,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     260: pop
     261: iinc          5, 1
     264: goto          219
     267: new           #26                 // class java/util/ArrayList
     270: dup
     271: iload_1
     272: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     275: astore        6
     277: iconst_0
     278: istore        7
     280: iload         7
     282: iload_1
     283: if_icmpge     325
     286: iload         7
     288: istore        8
     290: aload         6
     292: iload         8
     294: istore        9
     296: astore        22
     298: iconst_0
     299: istore        10
     301: new           #71                 // class java/util/LinkedHashSet
     304: dup
     305: invokespecial #72                 // Method java/util/LinkedHashSet."<init>":()V
     308: checkcast     #74                 // class java/util/Set
     311: nop
     312: aload         22
     314: swap
     315: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     318: pop
     319: iinc          7, 1
     322: goto          280
     325: aload         6
     327: checkcast     #12                 // class java/util/List
     330: astore        5
     332: iconst_0
     333: istore        6
     335: iload         6
     337: iload_2
     338: if_icmpge     519
     341: iload         6
     343: istore        7
     345: iconst_0
     346: istore        8
     348: invokestatic  #10                 // Method readInts:()Ljava/util/List;
     351: checkcast     #24                 // class java/lang/Iterable
     354: astore        9
     356: iconst_0
     357: istore        10
     359: aload         9
     361: astore        11
     363: new           #26                 // class java/util/ArrayList
     366: dup
     367: aload         9
     369: bipush        10
     371: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     374: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     377: checkcast     #38                 // class java/util/Collection
     380: astore        12
     382: iconst_0
     383: istore        13
     385: aload         11
     387: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     392: astore        14
     394: aload         14
     396: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     401: ifeq          449
     404: aload         14
     406: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     411: astore        15
     413: aload         12
     415: aload         15
     417: checkcast     #18                 // class java/lang/Number
     420: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     423: istore        16
     425: astore        17
     427: iconst_0
     428: istore        18
     430: iload         16
     432: iconst_1
     433: isub
     434: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     437: aload         17
     439: swap
     440: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     445: pop
     446: goto          394
     449: aload         12
     451: checkcast     #12                 // class java/util/List
     454: nop
     455: astore        19
     457: aload         19
     459: iconst_0
     460: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     465: checkcast     #18                 // class java/lang/Number
     468: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     471: istore        9
     473: aload         19
     475: iconst_1
     476: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     481: checkcast     #18                 // class java/lang/Number
     484: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     487: istore        10
     489: aload         5
     491: iload         9
     493: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     498: checkcast     #74                 // class java/util/Set
     501: iload         10
     503: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     506: invokeinterface #75,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     511: pop
     512: nop
     513: iinc          6, 1
     516: goto          335
     519: iconst_2
     520: istore        7
     522: new           #26                 // class java/util/ArrayList
     525: dup
     526: iload         7
     528: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     531: astore        8
     533: iconst_0
     534: istore        9
     536: iload         9
     538: iload         7
     540: if_icmpge     603
     543: iload         9
     545: istore        10
     547: aload         8
     549: iload         10
     551: istore        11
     553: astore        22
     555: iconst_0
     556: istore        12
     558: iconst_0
     559: istore        13
     561: iload_1
     562: newarray       boolean
     564: astore        14
     566: iload         13
     568: iload_1
     569: if_icmpge     588
     572: iload         13
     574: istore        15
     576: aload         14
     578: iload         15
     580: iconst_0
     581: bastore
     582: iinc          13, 1
     585: goto          566
     588: aload         14
     590: aload         22
     592: swap
     593: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     596: pop
     597: iinc          9, 1
     600: goto          536
     603: aload         8
     605: checkcast     #12                 // class java/util/List
     608: astore        6
     610: iconst_2
     611: istore        8
     613: new           #26                 // class java/util/ArrayList
     616: dup
     617: iload         8
     619: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     622: astore        9
     624: iconst_0
     625: istore        10
     627: iload         10
     629: iload         8
     631: if_icmpge     694
     634: iload         10
     636: istore        11
     638: aload         9
     640: iload         11
     642: istore        12
     644: astore        22
     646: iconst_0
     647: istore        13
     649: iconst_0
     650: istore        14
     652: iload_1
     653: newarray       int
     655: astore        15
     657: iload         14
     659: iload_1
     660: if_icmpge     679
     663: iload         14
     665: istore        16
     667: aload         15
     669: iload         16
     671: iconst_0
     672: iastore
     673: iinc          14, 1
     676: goto          657
     679: aload         15
     681: aload         22
     683: swap
     684: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     687: pop
     688: iinc          10, 1
     691: goto          627
     694: aload         9
     696: checkcast     #12                 // class java/util/List
     699: astore        7
     701: iconst_0
     702: istore        8
     704: aload         5
     706: checkcast     #38                 // class java/util/Collection
     709: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
     714: istore        9
     716: iload         8
     718: iload         9
     720: if_icmpge     927
     723: aload         5
     725: iload         8
     727: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     732: checkcast     #74                 // class java/util/Set
     735: invokeinterface #76,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     740: astore        10
     742: aload         10
     744: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     749: ifeq          921
     752: aload         10
     754: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     759: checkcast     #18                 // class java/lang/Number
     762: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     765: istore        11
     767: iload         11
     769: aload         4
     771: iload         8
     773: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     778: checkcast     #12                 // class java/util/List
     781: invokeinterface #77,  1           // InterfaceMethod java/util/List.size:()I
     786: if_icmpge     742
     789: aload         6
     791: iconst_0
     792: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     797: checkcast     #79                 // class "[Z"
     800: aload         4
     802: iload         8
     804: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     809: checkcast     #12                 // class java/util/List
     812: iload         11
     814: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     819: checkcast     #18                 // class java/lang/Number
     822: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     825: iconst_1
     826: bastore
     827: aload         6
     829: iconst_1
     830: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     835: checkcast     #79                 // class "[Z"
     838: aload         4
     840: iload         8
     842: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     847: checkcast     #12                 // class java/util/List
     850: aload         4
     852: iload         8
     854: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     859: checkcast     #12                 // class java/util/List
     862: invokeinterface #77,  1           // InterfaceMethod java/util/List.size:()I
     867: iconst_1
     868: isub
     869: iload         11
     871: isub
     872: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     877: checkcast     #18                 // class java/lang/Number
     880: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     883: iconst_1
     884: bastore
     885: aload         7
     887: iconst_1
     888: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     893: checkcast     #81                 // class "[I"
     896: astore        12
     898: iload         8
     900: istore        13
     902: aload         12
     904: iload         13
     906: iaload
     907: istore        14
     909: aload         12
     911: iload         13
     913: iload         14
     915: iconst_1
     916: iadd
     917: iastore
     918: goto          742
     921: iinc          8, 1
     924: goto          716
     927: iconst_0
     928: istore        8
     930: iconst_1
     931: istore        9
     933: aload         7
     935: iconst_1
     936: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     941: checkcast     #81                 // class "[I"
     944: astore        11
     946: iconst_0
     947: istore        12
     949: aload         11
     951: astore        13
     953: new           #26                 // class java/util/ArrayList
     956: dup
     957: invokespecial #64                 // Method java/util/ArrayList."<init>":()V
     960: checkcast     #38                 // class java/util/Collection
     963: astore        14
     965: iconst_0
     966: istore        15
     968: iconst_0
     969: istore        16
     971: aload         13
     973: arraylength
     974: istore        17
     976: iload         16
     978: iload         17
     980: if_icmpge     1029
     983: aload         13
     985: iload         16
     987: iaload
     988: istore        18
     990: iload         18
     992: istore        19
     994: iconst_0
     995: istore        20
     997: iload         19
     999: ifle          1006
    1002: iconst_1
    1003: goto          1007
    1006: iconst_0
    1007: ifeq          1023
    1010: aload         14
    1012: iload         18
    1014: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1017: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1022: pop
    1023: iinc          16, 1
    1026: goto          976
    1029: aload         14
    1031: checkcast     #12                 // class java/util/List
    1034: nop
    1035: invokeinterface #82,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
    1040: astore        10
    1042: aload         10
    1044: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1049: ifeq          1087
    1052: aload         10
    1054: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1059: checkcast     #18                 // class java/lang/Number
    1062: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1065: istore        11
    1067: iinc          8, 1
    1070: iload         9
    1072: i2l
    1073: iload         11
    1075: i2l
    1076: lmul
    1077: ldc           #83                 // int 1000000007
    1079: i2l
    1080: lrem
    1081: l2i
    1082: istore        9
    1084: goto          1042
    1087: iconst_0
    1088: istore        10
    1090: aload_3
    1091: checkcast     #38                 // class java/util/Collection
    1094: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
    1099: istore        11
    1101: iload         10
    1103: iload         11
    1105: if_icmpge     1488
    1108: aload         6
    1110: iconst_1
    1111: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1116: checkcast     #79                 // class "[Z"
    1119: iload         10
    1121: baload
    1122: ifeq          1170
    1125: aload         7
    1127: iconst_1
    1128: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1133: checkcast     #81                 // class "[I"
    1136: astore        12
    1138: aload_3
    1139: iload         10
    1141: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1146: checkcast     #18                 // class java/lang/Number
    1149: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1152: istore        13
    1154: aload         12
    1156: iload         13
    1158: iaload
    1159: istore        14
    1161: aload         12
    1163: iload         13
    1165: iload         14
    1167: iconst_m1
    1168: iadd
    1169: iastore
    1170: aload         6
    1172: iconst_0
    1173: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1178: checkcast     #79                 // class "[Z"
    1181: iload         10
    1183: baload
    1184: ifeq          1482
    1187: aload         7
    1189: iconst_0
    1190: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1195: checkcast     #81                 // class "[I"
    1198: astore        12
    1200: aload_3
    1201: iload         10
    1203: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1208: checkcast     #18                 // class java/lang/Number
    1211: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1214: istore        13
    1216: aload         12
    1218: iload         13
    1220: iaload
    1221: istore        14
    1223: aload         12
    1225: iload         13
    1227: iload         14
    1229: iconst_1
    1230: iadd
    1231: iastore
    1232: goto          1235
    1235: iconst_0
    1236: istore        12
    1238: iconst_1
    1239: istore        13
    1241: iconst_0
    1242: istore        14
    1244: aload_3
    1245: checkcast     #38                 // class java/util/Collection
    1248: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
    1253: istore        15
    1255: iload         14
    1257: iload         15
    1259: if_icmpge     1447
    1262: aload         7
    1264: iconst_0
    1265: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1270: checkcast     #81                 // class "[I"
    1273: iload         14
    1275: iaload
    1276: istore        16
    1278: aload         7
    1280: iconst_1
    1281: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1286: checkcast     #81                 // class "[I"
    1289: iload         14
    1291: iaload
    1292: istore        17
    1294: iload         14
    1296: aload_3
    1297: iload         10
    1299: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1304: checkcast     #18                 // class java/lang/Number
    1307: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1310: if_icmpne     1344
    1313: iload         16
    1315: iconst_1
    1316: isub
    1317: iload         17
    1319: if_icmpge     1329
    1322: iload         17
    1324: iconst_1
    1325: isub
    1326: goto          1331
    1329: iload         17
    1331: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1334: iconst_1
    1335: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1338: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1341: goto          1371
    1344: iload         16
    1346: iload         17
    1348: imul
    1349: iload         16
    1351: iload         17
    1353: invokestatic  #95                 // Method java/lang/Math.min:(II)I
    1356: isub
    1357: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1360: iload         16
    1362: iload         17
    1364: iadd
    1365: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1368: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1371: astore        18
    1373: aload         18
    1375: invokevirtual #100                // Method kotlin/Pair.component1:()Ljava/lang/Object;
    1378: checkcast     #18                 // class java/lang/Number
    1381: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1384: istore        19
    1386: aload         18
    1388: invokevirtual #103                // Method kotlin/Pair.component2:()Ljava/lang/Object;
    1391: checkcast     #18                 // class java/lang/Number
    1394: invokevirtual #22                 // Method java/lang/Number.intValue:()I
    1397: istore        20
    1399: iload         19
    1401: ifle          1412
    1404: iinc          12, 2
    1407: iload         19
    1409: goto          1425
    1412: iload         20
    1414: ifle          1441
    1417: iinc          12, 1
    1420: iload         20
    1422: goto          1425
    1425: istore        21
    1427: iload         13
    1429: i2l
    1430: iload         21
    1432: i2l
    1433: lmul
    1434: ldc           #83                 // int 1000000007
    1436: i2l
    1437: lrem
    1438: l2i
    1439: istore        13
    1441: iinc          14, 1
    1444: goto          1255
    1447: iload         12
    1449: iload         8
    1451: if_icmple     1465
    1454: iload         12
    1456: istore        8
    1458: iload         13
    1460: istore        9
    1462: goto          1482
    1465: iload         12
    1467: iload         8
    1469: if_icmpne     1482
    1472: iload         9
    1474: iload         13
    1476: iadd
    1477: ldc           #83                 // int 1000000007
    1479: irem
    1480: istore        9
    1482: iinc          10, 1
    1485: goto          1101
    1488: new           #105                // class java/lang/StringBuilder
    1491: dup
    1492: invokespecial #106                // Method java/lang/StringBuilder."<init>":()V
    1495: iload         8
    1497: invokevirtual #110                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1500: bipush        32
    1502: invokevirtual #113                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1505: iload         9
    1507: invokevirtual #110                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1510: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1513: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
    1516: swap
    1517: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1520: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #180                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #185                // 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  #189                // Method readLn:()Ljava/lang/String;
       3: checkcast     #191                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #193                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #195                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #201                // 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  #204                // Method readStrings:()Ljava/util/List;
       3: checkcast     #24                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #26                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #36                 // 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     #193                // 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/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #62,  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  #213                // Method main:()V
       3: return
}


package codeforces.round621

fun main() {
	val (n, m, _) = readInts()
	val special = readInts().map { it - 1 }
	val nei = List(n) { mutableListOf<Int>() }
	repeat(m) {
		val (u, v) = readInts().map { it - 1 }
		nei[u].add(v); nei[v].add(u)
	}
	val (s, t) = listOf(0, n - 1).map { bfs(nei, it) }
	val best = special.sortedBy { s[it] - t[it] }.fold(0 to -n) { (ans, maxPrev), i ->
		maxOf(ans, maxPrev + t[i]) to maxOf(maxPrev, s[i])
	}.first
	println(minOf(t[0], best + 1))
}

private fun bfs(nei: List<MutableList<Int>>, s: Int): List<Int> {
	val n = nei.size
	val queue = mutableListOf(s)
	val dist = MutableList(nei.size) { n }; dist[s] = 0
	var low = 0
	while (low < queue.size) {
		val v = queue[low++]
		for (u in nei[v]) {
			if (dist[u] == n) {
				dist[u] = dist[v] + 1
				queue.add(u)
			}
		}
	}
	return dist
}

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

Compiled from "d.kt"
public final class codeforces.round621.DKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      35: checkcast     #24                 // class java/lang/Iterable
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload         4
      45: astore        6
      47: new           #26                 // class java/util/ArrayList
      50: dup
      51: aload         4
      53: bipush        10
      55: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      58: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      61: checkcast     #38                 // class java/util/Collection
      64: astore        7
      66: iconst_0
      67: istore        8
      69: aload         6
      71: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      76: astore        9
      78: aload         9
      80: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      85: ifeq          133
      88: aload         9
      90: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      95: astore        10
      97: aload         7
      99: aload         10
     101: checkcast     #18                 // class java/lang/Number
     104: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     107: istore        11
     109: astore        20
     111: iconst_0
     112: istore        12
     114: iload         11
     116: iconst_1
     117: isub
     118: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: aload         20
     123: swap
     124: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          78
     133: aload         7
     135: checkcast     #12                 // class java/util/List
     138: nop
     139: astore_3
     140: new           #26                 // class java/util/ArrayList
     143: dup
     144: iload_1
     145: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     148: astore        5
     150: iconst_0
     151: istore        6
     153: iload         6
     155: iload_1
     156: if_icmpge     198
     159: iload         6
     161: istore        7
     163: aload         5
     165: iload         7
     167: istore        8
     169: astore        20
     171: iconst_0
     172: istore        9
     174: new           #26                 // class java/util/ArrayList
     177: dup
     178: invokespecial #64                 // Method java/util/ArrayList."<init>":()V
     181: checkcast     #12                 // class java/util/List
     184: nop
     185: aload         20
     187: swap
     188: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     191: pop
     192: iinc          6, 1
     195: goto          153
     198: aload         5
     200: checkcast     #12                 // class java/util/List
     203: astore        4
     205: iconst_0
     206: istore        5
     208: iload         5
     210: iload_2
     211: if_icmpge     415
     214: iload         5
     216: istore        6
     218: iconst_0
     219: istore        7
     221: invokestatic  #10                 // Method readInts:()Ljava/util/List;
     224: checkcast     #24                 // class java/lang/Iterable
     227: astore        8
     229: iconst_0
     230: istore        9
     232: aload         8
     234: astore        10
     236: new           #26                 // class java/util/ArrayList
     239: dup
     240: aload         8
     242: bipush        10
     244: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     247: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     250: checkcast     #38                 // class java/util/Collection
     253: astore        11
     255: iconst_0
     256: istore        12
     258: aload         10
     260: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     265: astore        13
     267: aload         13
     269: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     274: ifeq          322
     277: aload         13
     279: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        14
     286: aload         11
     288: aload         14
     290: checkcast     #18                 // class java/lang/Number
     293: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     296: istore        15
     298: astore        16
     300: iconst_0
     301: istore        17
     303: iload         15
     305: iconst_1
     306: isub
     307: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     310: aload         16
     312: swap
     313: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     318: pop
     319: goto          267
     322: aload         11
     324: checkcast     #12                 // class java/util/List
     327: nop
     328: astore        18
     330: aload         18
     332: iconst_0
     333: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     338: checkcast     #18                 // class java/lang/Number
     341: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     344: istore        8
     346: aload         18
     348: iconst_1
     349: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     354: checkcast     #18                 // class java/lang/Number
     357: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     360: istore        9
     362: aload         4
     364: iload         8
     366: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     371: checkcast     #12                 // class java/util/List
     374: iload         9
     376: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     379: invokeinterface #66,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     384: pop
     385: aload         4
     387: iload         9
     389: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     394: checkcast     #12                 // class java/util/List
     397: iload         8
     399: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     402: invokeinterface #66,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     407: pop
     408: nop
     409: iinc          5, 1
     412: goto          208
     415: iconst_2
     416: anewarray     #54                 // class java/lang/Integer
     419: astore        6
     421: aload         6
     423: iconst_0
     424: iconst_0
     425: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     428: aastore
     429: aload         6
     431: iconst_1
     432: iload_1
     433: iconst_1
     434: isub
     435: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     438: aastore
     439: aload         6
     441: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     444: checkcast     #24                 // class java/lang/Iterable
     447: astore        6
     449: iconst_0
     450: istore        7
     452: aload         6
     454: astore        8
     456: new           #26                 // class java/util/ArrayList
     459: dup
     460: aload         6
     462: bipush        10
     464: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     467: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     470: checkcast     #38                 // class java/util/Collection
     473: astore        9
     475: iconst_0
     476: istore        10
     478: aload         8
     480: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     485: astore        11
     487: aload         11
     489: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     494: ifeq          542
     497: aload         11
     499: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     504: astore        12
     506: aload         9
     508: aload         12
     510: checkcast     #18                 // class java/lang/Number
     513: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     516: istore        13
     518: astore        20
     520: iconst_0
     521: istore        14
     523: aload         4
     525: iload         13
     527: invokestatic  #74                 // Method bfs:(Ljava/util/List;I)Ljava/util/List;
     530: aload         20
     532: swap
     533: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     538: pop
     539: goto          487
     542: aload         9
     544: checkcast     #12                 // class java/util/List
     547: nop
     548: astore        5
     550: aload         5
     552: iconst_0
     553: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     558: checkcast     #12                 // class java/util/List
     561: astore        6
     563: aload         5
     565: iconst_1
     566: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     571: checkcast     #12                 // class java/util/List
     574: astore        7
     576: aload_3
     577: checkcast     #24                 // class java/lang/Iterable
     580: astore        9
     582: iconst_0
     583: istore        10
     585: aload         9
     587: new           #76                 // class codeforces/round621/DKt$main$$inlined$sortedBy$1
     590: dup
     591: aload         6
     593: aload         7
     595: invokespecial #79                 // Method codeforces/round621/DKt$main$$inlined$sortedBy$1."<init>":(Ljava/util/List;Ljava/util/List;)V
     598: checkcast     #81                 // class java/util/Comparator
     601: invokestatic  #85                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     604: checkcast     #24                 // class java/lang/Iterable
     607: astore        9
     609: iconst_0
     610: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     613: iload_1
     614: ineg
     615: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     618: invokestatic  #91                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     621: astore        10
     623: iconst_0
     624: istore        11
     626: aload         10
     628: astore        12
     630: aload         9
     632: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     637: astore        13
     639: aload         13
     641: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     646: ifeq          758
     649: aload         13
     651: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     656: astore        14
     658: aload         12
     660: aload         14
     662: checkcast     #18                 // class java/lang/Number
     665: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     668: istore        15
     670: astore        16
     672: iconst_0
     673: istore        17
     675: aload         16
     677: invokevirtual #96                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     680: checkcast     #18                 // class java/lang/Number
     683: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     686: istore        18
     688: aload         16
     690: invokevirtual #99                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     693: checkcast     #18                 // class java/lang/Number
     696: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     699: istore        19
     701: iload         18
     703: iload         19
     705: aload         7
     707: iload         15
     709: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     714: checkcast     #18                 // class java/lang/Number
     717: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     720: iadd
     721: invokestatic  #105                // Method java/lang/Math.max:(II)I
     724: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     727: iload         19
     729: aload         6
     731: iload         15
     733: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     738: checkcast     #18                 // class java/lang/Number
     741: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     744: invokestatic  #105                // Method java/lang/Math.max:(II)I
     747: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     750: invokestatic  #91                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     753: astore        12
     755: goto          639
     758: aload         12
     760: invokevirtual #108                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     763: checkcast     #18                 // class java/lang/Number
     766: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     769: istore        8
     771: aload         7
     773: iconst_0
     774: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     779: checkcast     #18                 // class java/lang/Number
     782: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     785: iload         8
     787: iconst_1
     788: iadd
     789: invokestatic  #111                // Method java/lang/Math.min:(II)I
     792: istore        9
     794: getstatic     #117                // Field java/lang/System.out:Ljava/io/PrintStream;
     797: iload         9
     799: invokevirtual #122                // Method java/io/PrintStream.println:(I)V
     802: return

  private static final java.util.List<java.lang.Integer> bfs(java.util.List<? extends java.util.List<java.lang.Integer>>, int);
    Code:
       0: aload_0
       1: invokeinterface #163,  1          // InterfaceMethod java/util/List.size:()I
       6: istore_2
       7: iconst_1
       8: anewarray     #54                 // class java/lang/Integer
      11: astore        4
      13: aload         4
      15: iconst_0
      16: iload_1
      17: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: aastore
      21: aload         4
      23: invokestatic  #166                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      26: astore_3
      27: aload_0
      28: invokeinterface #163,  1          // InterfaceMethod java/util/List.size:()I
      33: istore        5
      35: new           #26                 // class java/util/ArrayList
      38: dup
      39: iload         5
      41: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      44: astore        6
      46: iconst_0
      47: istore        7
      49: iload         7
      51: iload         5
      53: if_icmpge     88
      56: iload         7
      58: istore        8
      60: aload         6
      62: iload         8
      64: istore        9
      66: astore        11
      68: iconst_0
      69: istore        10
      71: iload_2
      72: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      75: aload         11
      77: swap
      78: invokevirtual #65                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      81: pop
      82: iinc          7, 1
      85: goto          49
      88: aload         6
      90: checkcast     #12                 // class java/util/List
      93: astore        4
      95: aload         4
      97: iload_1
      98: iconst_0
      99: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     102: invokeinterface #170,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     107: pop
     108: iconst_0
     109: istore        5
     111: iload         5
     113: aload_3
     114: invokeinterface #163,  1          // InterfaceMethod java/util/List.size:()I
     119: if_icmpge     248
     122: aload_3
     123: iload         5
     125: iinc          5, 1
     128: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     133: checkcast     #18                 // class java/lang/Number
     136: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     139: istore        6
     141: aload_0
     142: iload         6
     144: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     149: checkcast     #12                 // class java/util/List
     152: invokeinterface #171,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     157: astore        7
     159: aload         7
     161: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     166: ifeq          111
     169: aload         7
     171: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     176: checkcast     #18                 // class java/lang/Number
     179: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     182: istore        8
     184: aload         4
     186: iload         8
     188: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     193: checkcast     #18                 // class java/lang/Number
     196: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     199: iload_2
     200: if_icmpne     159
     203: aload         4
     205: iload         8
     207: aload         4
     209: iload         6
     211: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     216: checkcast     #18                 // class java/lang/Number
     219: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     222: iconst_1
     223: iadd
     224: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     227: invokeinterface #170,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     232: pop
     233: aload_3
     234: iload         8
     236: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     239: invokeinterface #66,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     244: pop
     245: goto          159
     248: aload         4
     250: areturn

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #184                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #190                // 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  #194                // Method readLn:()Ljava/lang/String;
       3: checkcast     #196                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #198                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #200                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #206                // 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  #209                // Method readStrings:()Ljava/util/List;
       3: checkcast     #24                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #26                 // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #36                 // 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     #198                // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #213                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #58                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #62,  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  #218                // Method main:()V
       3: return
}

Compiled from "Comparisons.kt"
public final class codeforces.round621.DKt$main$$inlined$sortedBy$1<T> implements java.util.Comparator {
  final java.util.List $s$inlined;

  final java.util.List $t$inlined;

  public codeforces.round621.DKt$main$$inlined$sortedBy$1(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #19                 // Field $s$inlined:Ljava/util/List;
       5: aload_0
       6: aload_2
       7: putfield      #21                 // Field $t$inlined:Ljava/util/List;
      10: aload_0
      11: invokespecial #24                 // Method java/lang/Object."<init>":()V
      14: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #31                 // class java/lang/Number
       4: invokevirtual #35                 // Method java/lang/Number.intValue:()I
       7: istore_3
       8: iconst_0
       9: istore        4
      11: aload_0
      12: getfield      #19                 // Field $s$inlined:Ljava/util/List;
      15: iload_3
      16: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      21: checkcast     #31                 // class java/lang/Number
      24: invokevirtual #35                 // Method java/lang/Number.intValue:()I
      27: aload_0
      28: getfield      #21                 // Field $t$inlined:Ljava/util/List;
      31: iload_3
      32: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #31                 // class java/lang/Number
      40: invokevirtual #35                 // Method java/lang/Number.intValue:()I
      43: isub
      44: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      47: checkcast     #49                 // class java/lang/Comparable
      50: aload_2
      51: checkcast     #31                 // class java/lang/Number
      54: invokevirtual #35                 // Method java/lang/Number.intValue:()I
      57: istore_3
      58: astore        5
      60: iconst_0
      61: istore        4
      63: aload_0
      64: getfield      #19                 // Field $s$inlined:Ljava/util/List;
      67: iload_3
      68: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      73: checkcast     #31                 // class java/lang/Number
      76: invokevirtual #35                 // Method java/lang/Number.intValue:()I
      79: aload_0
      80: getfield      #21                 // Field $t$inlined:Ljava/util/List;
      83: iload_3
      84: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #31                 // class java/lang/Number
      92: invokevirtual #35                 // Method java/lang/Number.intValue:()I
      95: isub
      96: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      99: aload         5
     101: swap
     102: checkcast     #49                 // class java/lang/Comparable
     105: invokestatic  #55                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
     108: ireturn
}