package codechef.snackdown2021.qual

private fun solve() {
	val (n, m) = readInts()
	val nei = List(n) { mutableListOf<Int>() }
	repeat(m) {
		val (u, v) = readInts().map { it - 1 }
		nei[u].add(v); nei[v].add(u)
	}
	val degree = IntArray(n) { nei[it].size }
	val byDegree = List(n) { mutableSetOf<Int>() }
	for (v in nei.indices) byDegree[degree[v]].add(v)
	val mark = BooleanArray(n)
	var minDegree = 0
	var maxSeenMinDegree = 0
	val ans = IntArray(n)
	for (iter in nei.indices) {
		while (byDegree[minDegree].isEmpty()) minDegree++
		maxSeenMinDegree = maxOf(maxSeenMinDegree, minDegree)
		val v = byDegree[minDegree].first()
		ans[v] = n - iter
		byDegree[minDegree].remove(v)
		mark[v] = true
		for (u in nei[v]) {
			if (mark[u]) continue
			byDegree[degree[u]].remove(u)
			degree[u]--
			byDegree[degree[u]].add(u)
			minDegree = minOf(minDegree, degree[u])
		}
	}
	println(maxSeenMinDegree)
	println(ans.joinToString(" "))
}

@Suppress("UNUSED_PARAMETER") // Kotlin 1.2
fun main(args: Array<String>) = 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 "d_tl.kt"
public final class codechef.snackdown2021.qual.D_tlKt {
  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: new           #24                 // class java/util/ArrayList
      35: dup
      36: iload_1
      37: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      40: astore        4
      42: iconst_0
      43: istore        5
      45: iload         5
      47: iload_1
      48: if_icmpge     90
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        18
      63: iconst_0
      64: istore        8
      66: new           #24                 // class java/util/ArrayList
      69: dup
      70: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
      73: checkcast     #12                 // class java/util/List
      76: nop
      77: aload         18
      79: swap
      80: invokevirtual #34                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      83: pop
      84: iinc          5, 1
      87: goto          45
      90: aload         4
      92: checkcast     #12                 // class java/util/List
      95: astore_3
      96: iconst_0
      97: istore        4
      99: iload         4
     101: iload_2
     102: if_icmpge     304
     105: iload         4
     107: istore        5
     109: iconst_0
     110: istore        6
     112: invokestatic  #10                 // Method readInts:()Ljava/util/List;
     115: checkcast     #36                 // class java/lang/Iterable
     118: astore        7
     120: iconst_0
     121: istore        8
     123: aload         7
     125: astore        9
     127: new           #24                 // class java/util/ArrayList
     130: dup
     131: aload         7
     133: bipush        10
     135: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     138: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     141: checkcast     #44                 // class java/util/Collection
     144: astore        10
     146: iconst_0
     147: istore        11
     149: aload         9
     151: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     156: astore        12
     158: aload         12
     160: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     165: ifeq          213
     168: aload         12
     170: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     175: astore        13
     177: aload         10
     179: aload         13
     181: checkcast     #18                 // class java/lang/Number
     184: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     187: istore        14
     189: astore        15
     191: iconst_0
     192: istore        16
     194: iload         14
     196: iconst_1
     197: isub
     198: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: aload         15
     203: swap
     204: invokeinterface #65,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     209: pop
     210: goto          158
     213: aload         10
     215: checkcast     #12                 // class java/util/List
     218: nop
     219: astore        17
     221: aload         17
     223: iconst_0
     224: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     229: checkcast     #18                 // class java/lang/Number
     232: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     235: istore        7
     237: aload         17
     239: iconst_1
     240: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     245: checkcast     #18                 // class java/lang/Number
     248: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     251: istore        8
     253: aload_3
     254: iload         7
     256: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     261: checkcast     #12                 // class java/util/List
     264: iload         8
     266: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     269: invokeinterface #66,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     274: pop
     275: aload_3
     276: iload         8
     278: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     283: checkcast     #12                 // class java/util/List
     286: iload         7
     288: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     291: invokeinterface #66,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     296: pop
     297: nop
     298: iinc          4, 1
     301: goto          99
     304: iconst_0
     305: istore        5
     307: iload_1
     308: newarray       int
     310: astore        6
     312: iload         5
     314: iload_1
     315: if_icmpge     349
     318: iload         5
     320: istore        7
     322: aload         6
     324: iload         7
     326: aload_3
     327: iload         7
     329: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     334: checkcast     #12                 // class java/util/List
     337: invokeinterface #69,  1           // InterfaceMethod java/util/List.size:()I
     342: iastore
     343: iinc          5, 1
     346: goto          312
     349: aload         6
     351: astore        4
     353: new           #24                 // class java/util/ArrayList
     356: dup
     357: iload_1
     358: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     361: astore        6
     363: iconst_0
     364: istore        7
     366: iload         7
     368: iload_1
     369: if_icmpge     411
     372: iload         7
     374: istore        8
     376: aload         6
     378: iload         8
     380: istore        9
     382: astore        18
     384: iconst_0
     385: istore        10
     387: new           #71                 // class java/util/LinkedHashSet
     390: dup
     391: invokespecial #72                 // Method java/util/LinkedHashSet."<init>":()V
     394: checkcast     #74                 // class java/util/Set
     397: nop
     398: aload         18
     400: swap
     401: invokevirtual #34                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     404: pop
     405: iinc          7, 1
     408: goto          366
     411: aload         6
     413: checkcast     #12                 // class java/util/List
     416: astore        5
     418: iconst_0
     419: istore        6
     421: aload_3
     422: checkcast     #44                 // class java/util/Collection
     425: invokeinterface #75,  1           // InterfaceMethod java/util/Collection.size:()I
     430: istore        7
     432: iload         6
     434: iload         7
     436: if_icmpge     471
     439: aload         5
     441: aload         4
     443: iload         6
     445: iaload
     446: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     451: checkcast     #74                 // class java/util/Set
     454: iload         6
     456: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     459: invokeinterface #76,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     464: pop
     465: iinc          6, 1
     468: goto          432
     471: iload_1
     472: newarray       boolean
     474: astore        6
     476: iconst_0
     477: istore        7
     479: iconst_0
     480: istore        8
     482: iload_1
     483: newarray       int
     485: astore        9
     487: iconst_0
     488: istore        10
     490: aload_3
     491: checkcast     #44                 // class java/util/Collection
     494: invokeinterface #75,  1           // InterfaceMethod java/util/Collection.size:()I
     499: istore        11
     501: iload         10
     503: iload         11
     505: if_icmpge     744
     508: aload         5
     510: iload         7
     512: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     517: checkcast     #74                 // class java/util/Set
     520: invokeinterface #79,  1           // InterfaceMethod java/util/Set.isEmpty:()Z
     525: ifeq          534
     528: iinc          7, 1
     531: goto          508
     534: iload         8
     536: iload         7
     538: invokestatic  #85                 // Method java/lang/Math.max:(II)I
     541: istore        8
     543: aload         5
     545: iload         7
     547: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     552: checkcast     #36                 // class java/lang/Iterable
     555: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
     558: checkcast     #18                 // class java/lang/Number
     561: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     564: istore        12
     566: aload         9
     568: iload         12
     570: iload_1
     571: iload         10
     573: isub
     574: iastore
     575: aload         5
     577: iload         7
     579: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     584: checkcast     #74                 // class java/util/Set
     587: iload         12
     589: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     592: invokeinterface #92,  2           // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     597: pop
     598: aload         6
     600: iload         12
     602: iconst_1
     603: bastore
     604: aload_3
     605: iload         12
     607: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     612: checkcast     #12                 // class java/util/List
     615: invokeinterface #93,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     620: astore        13
     622: aload         13
     624: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     629: ifeq          738
     632: aload         13
     634: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     639: checkcast     #18                 // class java/lang/Number
     642: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     645: istore        14
     647: aload         6
     649: iload         14
     651: baload
     652: ifne          622
     655: aload         5
     657: aload         4
     659: iload         14
     661: iaload
     662: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     667: checkcast     #74                 // class java/util/Set
     670: iload         14
     672: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     675: invokeinterface #92,  2           // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     680: pop
     681: aload         4
     683: iload         14
     685: iaload
     686: istore        15
     688: aload         4
     690: iload         14
     692: iload         15
     694: iconst_m1
     695: iadd
     696: iastore
     697: aload         5
     699: aload         4
     701: iload         14
     703: iaload
     704: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     709: checkcast     #74                 // class java/util/Set
     712: iload         14
     714: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     717: invokeinterface #76,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     722: pop
     723: iload         7
     725: aload         4
     727: iload         14
     729: iaload
     730: invokestatic  #96                 // Method java/lang/Math.min:(II)I
     733: istore        7
     735: goto          622
     738: iinc          10, 1
     741: goto          501
     744: getstatic     #102                // Field java/lang/System.out:Ljava/io/PrintStream;
     747: iload         8
     749: invokevirtual #107                // Method java/io/PrintStream.println:(I)V
     752: aload         9
     754: ldc           #109                // String
     756: checkcast     #111                // class java/lang/CharSequence
     759: aconst_null
     760: aconst_null
     761: iconst_0
     762: aconst_null
     763: aconst_null
     764: bipush        62
     766: aconst_null
     767: invokestatic  #117                // 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;
     770: getstatic     #102                // Field java/lang/System.out:Ljava/io/PrintStream;
     773: swap
     774: invokevirtual #120                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     777: return

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #157                // String args
       3: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #166                // Method readInt:()I
       9: istore_1
      10: iconst_0
      11: istore_2
      12: iload_2
      13: iload_1
      14: if_icmpge     31
      17: iload_2
      18: istore_3
      19: iconst_0
      20: istore        4
      22: invokestatic  #168                // Method solve:()V
      25: iinc          2, 1
      28: goto          12
      31: return

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

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

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


package codechef.snackdown2021.preelim

import java.util.*

private fun solve(magic: Int = 96): List<Int> {
	val n = readInt()
	val e = List(n) { readLn() }
	val diff = (n + 1) / 2
	fun won(i: Int, j: Int) = e[i][j] == '1'
	val level = IntArray(n)
	val r = Random(566)
	var tries = 0
	for (mid in e.indices.shuffled(r)) {
		val (weak, strong) = (e.indices - mid).partition { won(mid, it) }.toList().map { it.toMutableList() }
		if (maxOf(weak.size, strong.size) > diff + 1) continue
		if (++tries == magic) break
		level.fill(0)
		for (a in listOf(weak, strong)) {
			for (i in a.indices) for (j in 0 until i) {
				if (won(a[i], a[j])) level[a[i]]++ else level[a[j]]++
			}
			a.sortBy { level[it] }
		}
		val p = weak + mid + strong
		var good = true
		for (i in p.indices) for (j in i + 1..minOf(i + diff, n - 1)) {
			if (won(p[i], p[j])) {
				good = false
				break
			}
		}
		if (good) {
			return p.toIntArray().reversed().map { it + 1 }
		}
	}
	return listOf(-1)
}

@Suppress("UNUSED_PARAMETER") // Kotlin 1.2
fun main(args: Array<String>) = repeat(readInt()) { println(solve().joinToString(" ")) }

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

Compiled from "Comparisons.kt"
public final class codechef.snackdown2021.preelim.Goodranking_randomizedKt$solve$$inlined$sortBy$1<T> implements java.util.Comparator {
  final int[] $level$inlined;

  public codechef.snackdown2021.preelim.Goodranking_randomizedKt$solve$$inlined$sortBy$1(int[]);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $level$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 $level$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 $level$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 "goodranking_randomized.kt"
public final class codechef.snackdown2021.preelim.Goodranking_randomizedKt {
  private static final java.util.List<java.lang.Integer> solve(int);
    Code:
       0: invokestatic  #11                 // Method readInt:()I
       3: istore_1
       4: new           #13                 // class java/util/ArrayList
       7: dup
       8: iload_1
       9: invokespecial #17                 // Method java/util/ArrayList."<init>":(I)V
      12: astore_3
      13: iconst_0
      14: istore        4
      16: iload         4
      18: iload_1
      19: if_icmpge     52
      22: iload         4
      24: istore        5
      26: aload_3
      27: iload         5
      29: istore        6
      31: astore        23
      33: iconst_0
      34: istore        7
      36: invokestatic  #21                 // Method readLn:()Ljava/lang/String;
      39: aload         23
      41: swap
      42: invokevirtual #25                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      45: pop
      46: iinc          4, 1
      49: goto          16
      52: aload_3
      53: checkcast     #27                 // class java/util/List
      56: astore_2
      57: iload_1
      58: iconst_1
      59: iadd
      60: iconst_2
      61: idiv
      62: istore_3
      63: iload_1
      64: newarray       int
      66: astore        4
      68: new           #29                 // class java/util/Random
      71: dup
      72: ldc2_w        #30                 // long 566l
      75: invokespecial #34                 // Method java/util/Random."<init>":(J)V
      78: astore        5
      80: iconst_0
      81: istore        6
      83: aload_2
      84: checkcast     #36                 // class java/util/Collection
      87: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      90: checkcast     #44                 // class java/lang/Iterable
      93: aload         5
      95: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.shuffled:(Ljava/lang/Iterable;Ljava/util/Random;)Ljava/util/List;
      98: invokeinterface #52,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     103: astore        7
     105: aload         7
     107: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     112: ifeq          934
     115: aload         7
     117: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     122: checkcast     #64                 // class java/lang/Number
     125: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     128: istore        8
     130: aload_2
     131: checkcast     #36                 // class java/util/Collection
     134: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     137: checkcast     #44                 // class java/lang/Iterable
     140: iload         8
     142: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     145: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;
     148: checkcast     #44                 // class java/lang/Iterable
     151: astore        10
     153: iconst_0
     154: istore        11
     156: new           #13                 // class java/util/ArrayList
     159: dup
     160: invokespecial #80                 // Method java/util/ArrayList."<init>":()V
     163: astore        12
     165: new           #13                 // class java/util/ArrayList
     168: dup
     169: invokespecial #80                 // Method java/util/ArrayList."<init>":()V
     172: astore        13
     174: aload         10
     176: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     181: astore        14
     183: aload         14
     185: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     190: ifeq          247
     193: aload         14
     195: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     200: astore        15
     202: aload         15
     204: checkcast     #64                 // class java/lang/Number
     207: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     210: istore        16
     212: iconst_0
     213: istore        17
     215: aload_2
     216: iload         8
     218: iload         16
     220: invokestatic  #85                 // Method solve$won:(Ljava/util/List;II)Z
     223: ifeq          236
     226: aload         12
     228: aload         15
     230: invokevirtual #25                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     233: goto          243
     236: aload         13
     238: aload         15
     240: invokevirtual #25                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     243: pop
     244: goto          183
     247: new           #87                 // class kotlin/Pair
     250: dup
     251: aload         12
     253: aload         13
     255: invokespecial #90                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     258: invokestatic  #96                 // Method kotlin/TuplesKt.toList:(Lkotlin/Pair;)Ljava/util/List;
     261: checkcast     #44                 // class java/lang/Iterable
     264: astore        10
     266: iconst_0
     267: istore        11
     269: aload         10
     271: astore        12
     273: new           #13                 // class java/util/ArrayList
     276: dup
     277: aload         10
     279: bipush        10
     281: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     284: invokespecial #17                 // Method java/util/ArrayList."<init>":(I)V
     287: checkcast     #36                 // class java/util/Collection
     290: astore        13
     292: iconst_0
     293: istore        14
     295: aload         12
     297: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     302: astore        15
     304: aload         15
     306: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     311: ifeq          357
     314: aload         15
     316: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     321: astore        16
     323: aload         13
     325: aload         16
     327: checkcast     #27                 // class java/util/List
     330: astore        17
     332: astore        23
     334: iconst_0
     335: istore        18
     337: aload         17
     339: checkcast     #36                 // class java/util/Collection
     342: invokestatic  #104                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     345: aload         23
     347: swap
     348: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     353: pop
     354: goto          304
     357: aload         13
     359: checkcast     #27                 // class java/util/List
     362: nop
     363: astore        9
     365: aload         9
     367: iconst_0
     368: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     373: checkcast     #27                 // class java/util/List
     376: astore        10
     378: aload         9
     380: iconst_1
     381: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     386: checkcast     #27                 // class java/util/List
     389: astore        11
     391: aload         10
     393: invokeinterface #112,  1          // InterfaceMethod java/util/List.size:()I
     398: aload         11
     400: invokeinterface #112,  1          // InterfaceMethod java/util/List.size:()I
     405: invokestatic  #118                // Method java/lang/Math.max:(II)I
     408: iload_3
     409: iconst_1
     410: iadd
     411: if_icmpgt     105
     414: iinc          6, 1
     417: iload         6
     419: iload_0
     420: if_icmpeq     934
     423: aload         4
     425: iconst_0
     426: iconst_0
     427: iconst_0
     428: bipush        6
     430: aconst_null
     431: invokestatic  #124                // Method kotlin/collections/ArraysKt.fill$default:([IIIIILjava/lang/Object;)V
     434: iconst_2
     435: anewarray     #27                 // class java/util/List
     438: astore        13
     440: aload         13
     442: iconst_0
     443: aload         10
     445: aastore
     446: aload         13
     448: iconst_1
     449: aload         11
     451: aastore
     452: aload         13
     454: invokestatic  #128                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     457: invokeinterface #52,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     462: astore        12
     464: aload         12
     466: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     471: ifeq          675
     474: aload         12
     476: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     481: checkcast     #27                 // class java/util/List
     484: astore        13
     486: iconst_0
     487: istore        14
     489: aload         13
     491: checkcast     #36                 // class java/util/Collection
     494: invokeinterface #129,  1          // InterfaceMethod java/util/Collection.size:()I
     499: istore        15
     501: iload         14
     503: iload         15
     505: if_icmpge     636
     508: iconst_0
     509: istore        16
     511: iload         16
     513: iload         14
     515: if_icmpge     630
     518: aload_2
     519: aload         13
     521: iload         14
     523: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     528: checkcast     #64                 // class java/lang/Number
     531: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     534: aload         13
     536: iload         16
     538: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     543: checkcast     #64                 // class java/lang/Number
     546: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     549: invokestatic  #85                 // Method solve$won:(Ljava/util/List;II)Z
     552: ifeq          591
     555: aload         13
     557: iload         14
     559: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     564: checkcast     #64                 // class java/lang/Number
     567: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     570: istore        17
     572: aload         4
     574: iload         17
     576: iaload
     577: istore        18
     579: aload         4
     581: iload         17
     583: iload         18
     585: iconst_1
     586: iadd
     587: iastore
     588: goto          624
     591: aload         13
     593: iload         16
     595: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     600: checkcast     #64                 // class java/lang/Number
     603: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     606: istore        17
     608: aload         4
     610: iload         17
     612: iaload
     613: istore        18
     615: aload         4
     617: iload         17
     619: iload         18
     621: iconst_1
     622: iadd
     623: iastore
     624: iinc          16, 1
     627: goto          511
     630: iinc          14, 1
     633: goto          501
     636: aload         13
     638: astore        14
     640: iconst_0
     641: istore        15
     643: aload         14
     645: invokeinterface #112,  1          // InterfaceMethod java/util/List.size:()I
     650: iconst_1
     651: if_icmple     671
     654: aload         14
     656: new           #131                // class codechef/snackdown2021/preelim/Goodranking_randomizedKt$solve$$inlined$sortBy$1
     659: dup
     660: aload         4
     662: invokespecial #134                // Method codechef/snackdown2021/preelim/Goodranking_randomizedKt$solve$$inlined$sortBy$1."<init>":([I)V
     665: checkcast     #136                // class java/util/Comparator
     668: invokestatic  #140                // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
     671: nop
     672: goto          464
     675: aload         10
     677: checkcast     #36                 // class java/util/Collection
     680: iload         8
     682: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     685: invokestatic  #144                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     688: checkcast     #36                 // class java/util/Collection
     691: aload         11
     693: checkcast     #44                 // class java/lang/Iterable
     696: invokestatic  #147                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     699: astore        12
     701: iconst_1
     702: istore        13
     704: iconst_0
     705: istore        14
     707: aload         12
     709: checkcast     #36                 // class java/util/Collection
     712: invokeinterface #129,  1          // InterfaceMethod java/util/Collection.size:()I
     717: istore        15
     719: iload         14
     721: iload         15
     723: if_icmpge     813
     726: iload         14
     728: iconst_1
     729: iadd
     730: istore        16
     732: iload         14
     734: iload_3
     735: iadd
     736: iload_1
     737: iconst_1
     738: isub
     739: invokestatic  #150                // Method java/lang/Math.min:(II)I
     742: istore        17
     744: iload         16
     746: iload         17
     748: if_icmpgt     807
     751: aload_2
     752: aload         12
     754: iload         14
     756: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     761: checkcast     #64                 // class java/lang/Number
     764: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     767: aload         12
     769: iload         16
     771: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     776: checkcast     #64                 // class java/lang/Number
     779: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     782: invokestatic  #85                 // Method solve$won:(Ljava/util/List;II)Z
     785: ifeq          794
     788: iconst_0
     789: istore        13
     791: goto          807
     794: iload         16
     796: iload         17
     798: if_icmpeq     807
     801: iinc          16, 1
     804: goto          751
     807: iinc          14, 1
     810: goto          719
     813: iload         13
     815: ifeq          105
     818: aload         12
     820: checkcast     #36                 // class java/util/Collection
     823: invokestatic  #154                // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     826: invokestatic  #158                // Method kotlin/collections/ArraysKt.reversed:([I)Ljava/util/List;
     829: checkcast     #44                 // class java/lang/Iterable
     832: astore        14
     834: iconst_0
     835: istore        15
     837: aload         14
     839: astore        16
     841: new           #13                 // class java/util/ArrayList
     844: dup
     845: aload         14
     847: bipush        10
     849: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     852: invokespecial #17                 // Method java/util/ArrayList."<init>":(I)V
     855: checkcast     #36                 // class java/util/Collection
     858: astore        17
     860: iconst_0
     861: istore        18
     863: aload         16
     865: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     870: astore        19
     872: aload         19
     874: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     879: ifeq          927
     882: aload         19
     884: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     889: astore        20
     891: aload         17
     893: aload         20
     895: checkcast     #64                 // class java/lang/Number
     898: invokevirtual #67                 // Method java/lang/Number.intValue:()I
     901: istore        21
     903: astore        23
     905: iconst_0
     906: istore        22
     908: iload         21
     910: iconst_1
     911: iadd
     912: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     915: aload         23
     917: swap
     918: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     923: pop
     924: goto          872
     927: aload         17
     929: checkcast     #27                 // class java/util/List
     932: nop
     933: areturn
     934: iconst_m1
     935: invokestatic  #73                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     938: invokestatic  #161                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     941: areturn

  static java.util.List solve$default(int, int, java.lang.Object);
    Code:
       0: iload_1
       1: iconst_1
       2: iand
       3: ifeq          9
       6: bipush        96
       8: istore_0
       9: iload_0
      10: invokestatic  #208                // Method solve:(I)Ljava/util/List;
      13: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #213                // String args
       3: invokestatic  #219                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #11                 // Method readInt:()I
       9: istore_1
      10: iconst_0
      11: istore_2
      12: iload_2
      13: iload_1
      14: if_icmpge     61
      17: iload_2
      18: istore_3
      19: iconst_0
      20: istore        4
      22: iconst_0
      23: iconst_1
      24: aconst_null
      25: invokestatic  #221                // Method solve$default:(IILjava/lang/Object;)Ljava/util/List;
      28: checkcast     #44                 // class java/lang/Iterable
      31: ldc           #223                // String
      33: checkcast     #225                // class java/lang/CharSequence
      36: aconst_null
      37: aconst_null
      38: iconst_0
      39: aconst_null
      40: aconst_null
      41: bipush        62
      43: aconst_null
      44: invokestatic  #229                // 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;
      47: getstatic     #235                // Field java/lang/System.out:Ljava/io/PrintStream;
      50: swap
      51: invokevirtual #241                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      54: nop
      55: iinc          2, 1
      58: goto          12
      61: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #248                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #251                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: checkcast     #225                // class java/lang/CharSequence
      10: invokestatic  #257                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      13: invokevirtual #260                // Method java/lang/Object.toString:()Ljava/lang/String;
      16: areturn

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

  private static final boolean solve$won(java.util.List<java.lang.String>, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #267                // class java/lang/String
      10: iload_2
      11: invokevirtual #271                // Method java/lang/String.charAt:(I)C
      14: bipush        49
      16: if_icmpne     23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: ireturn
}


package codechef.snackdown2021.preelim

private const val MAX_S = 200_000

@Suppress("UNUSED_PARAMETER") // Kotlin 1.2
fun main(args: Array<String>) {
	readLn()
	val a = readInts()
	val fenwickTree = FenwickTree(MAX_S + 1)
	var ans = 1.toModular()
	for (x in a) {
		val added = 1 + fenwickTree.sum(x).toModular()
		fenwickTree[x] = (fenwickTree[x].toInt() + added).x.toLong()
		ans += added
	}
	println(ans)
}

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

class FenwickTree(n: Int) {
	var t: LongArray
	fun add(i: Int, value: Long) {
		var j = i
		while (j < t.size) {
			t[j] += value
			j += j + 1 and -(j + 1)
		}
	}

	fun sum(i: Int): Long {
		var j = i
		var res: Long = 0
		j--
		while (j >= 0) {
			res += t[j]
			j -= j + 1 and -(j + 1)
		}
		return res
	}

	fun sum(start: Int, end: Int): Long {
		return sum(end) - sum(start)
	}

	operator fun get(i: Int): Long {
		return sum(i, i + 1)
	}

	operator fun set(i: Int, value: Long) {
		add(i, value - get(i))
	}

	init {
		t = LongArray(n)
	}
}

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

Compiled from "slippers.kt"
public final class codechef.snackdown2021.preelim.SlippersKt {
  private static final int MAX_S;

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #19                 // Method readLn:()Ljava/lang/String;
       9: pop
      10: invokestatic  #23                 // Method readInts:()Ljava/util/List;
      13: astore_1
      14: new           #25                 // class codechef/snackdown2021/preelim/FenwickTree
      17: dup
      18: ldc           #26                 // int 200001
      20: invokespecial #30                 // Method codechef/snackdown2021/preelim/FenwickTree."<init>":(I)V
      23: astore_2
      24: iconst_1
      25: invokestatic  #34                 // Method toModular:(I)Lcodechef/snackdown2021/preelim/Modular;
      28: astore_3
      29: aload_1
      30: invokeinterface #40,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      35: astore        4
      37: aload         4
      39: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      44: ifeq          109
      47: aload         4
      49: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      54: checkcast     #52                 // class java/lang/Number
      57: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      60: istore        5
      62: iconst_1
      63: aload_2
      64: iload         5
      66: invokevirtual #60                 // Method codechef/snackdown2021/preelim/FenwickTree.sum:(I)J
      69: invokestatic  #63                 // Method toModular:(J)Lcodechef/snackdown2021/preelim/Modular;
      72: invokestatic  #67                 // Method plus:(ILcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      75: astore        6
      77: aload_2
      78: iload         5
      80: aload_2
      81: iload         5
      83: invokevirtual #70                 // Method codechef/snackdown2021/preelim/FenwickTree.get:(I)J
      86: l2i
      87: aload         6
      89: invokestatic  #67                 // Method plus:(ILcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      92: invokevirtual #75                 // Method codechef/snackdown2021/preelim/Modular.getX:()I
      95: i2l
      96: invokevirtual #79                 // Method codechef/snackdown2021/preelim/FenwickTree.set:(IJ)V
      99: aload_3
     100: aload         6
     102: invokevirtual #82                 // Method codechef/snackdown2021/preelim/Modular.plus:(Lcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
     105: astore_3
     106: goto          37
     109: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     112: aload_3
     113: invokevirtual #94                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     116: return

  private static final codechef.snackdown2021.preelim.Modular toModular(int);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: iload_0
       5: invokespecial #106                // Method codechef/snackdown2021/preelim/Modular."<init>":(I)V
       8: areturn

  private static final codechef.snackdown2021.preelim.Modular toModular(long);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: lload_0
       5: invokespecial #110                // Method codechef/snackdown2021/preelim/Modular."<init>":(J)V
       8: areturn

  private static final codechef.snackdown2021.preelim.Modular plus(int, codechef.snackdown2021.preelim.Modular);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: iload_0
       5: invokespecial #106                // Method codechef/snackdown2021/preelim/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #82                 // Method codechef/snackdown2021/preelim/Modular.plus:(Lcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      12: areturn

  private static final codechef.snackdown2021.preelim.Modular minus(int, codechef.snackdown2021.preelim.Modular);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: iload_0
       5: invokespecial #106                // Method codechef/snackdown2021/preelim/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #116                // Method codechef/snackdown2021/preelim/Modular.minus:(Lcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      12: areturn

  private static final codechef.snackdown2021.preelim.Modular times(int, codechef.snackdown2021.preelim.Modular);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: iload_0
       5: invokespecial #106                // Method codechef/snackdown2021/preelim/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #120                // Method codechef/snackdown2021/preelim/Modular.times:(Lcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      12: areturn

  private static final codechef.snackdown2021.preelim.Modular div(int, codechef.snackdown2021.preelim.Modular);
    Code:
       0: new           #72                 // class codechef/snackdown2021/preelim/Modular
       3: dup
       4: iload_0
       5: invokespecial #106                // Method codechef/snackdown2021/preelim/Modular."<init>":(I)V
       8: aload_1
       9: invokevirtual #124                // Method codechef/snackdown2021/preelim/Modular.div:(Lcodechef/snackdown2021/preelim/Modular;)Lcodechef/snackdown2021/preelim/Modular;
      12: areturn

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #130                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #133                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: checkcast     #135                // class java/lang/CharSequence
      10: invokestatic  #141                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      13: invokevirtual #144                // Method java/lang/Object.toString:()Ljava/lang/String;
      16: areturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #19                 // Method readLn:()Ljava/lang/String;
       3: checkcast     #135                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #148                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #150                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #154                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: areturn

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

  public static final codechef.snackdown2021.preelim.Modular access$toModular(int);
    Code:
       0: iload_0
       1: invokestatic  #34                 // Method toModular:(I)Lcodechef/snackdown2021/preelim/Modular;
       4: areturn
}


package codechef.snackdown2021.preelim

import java.util.*

@Suppress("UNUSED_PARAMETER") // Kotlin 1.2
fun main(args: Array<String>) {
	val (tests, n) = readInts()
	val desired = n / 2
	val all = 1..n

	val cnk = List(n + 1) { LongArray(it + 1) { 1 } }
	for (i in 2..n) for (j in 1 until i) cnk[i][j] = cnk[i - 1][j - 1] + cnk[i - 1][j]
	fun cnk(i: Int, j: Int) = cnk[i].getOrElse(j) { 0 }
	fun prob(asked: Int, ones: Int, density: Int) =
		1.0 * cnk(asked, ones) * cnk(n - asked, density - ones) / cnk(n, density)
	val prob = List(n + 1) { asked -> DoubleArray(asked + 1) { ones ->
		prob(asked, ones, desired) / all.sumOf { prob(asked, ones, it) }
	} }
	val random = Random(566)
	fun shuffle() = (0 until n).shuffled(random)

	fun solve() {
		val verShuffle = shuffle()
		val horShuffle = List(n) { shuffle() }
		fun ask(x: Int, y: Int): Int {
			println("? ${verShuffle[x] + 1} ${horShuffle[x][y] + 1}")
			return readInt()
		}
		fun answer(x: Int) {
			println("! ${verShuffle[x] + 1}")
		}
		val asked = IntArray(n)
		val ones = IntArray(n)
		val treeSet = TreeSet<Int>(compareBy({ prob[asked[it]][ones[it]] }, { it }))
		treeSet.addAll(asked.indices)
		while (true) {
			val x = treeSet.pollLast()!!
			ones[x] += ask(x, asked[x]++)
			if (asked[x] == n && ones[x] == desired) return answer(x)
			treeSet.add(x)
		}
	}
	repeat(tests) { solve() }
}

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

Compiled from "guessrow.kt"
public final class codechef.snackdown2021.preelim.GuessrowKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #19                 // Method readInts:()Ljava/util/List;
       9: astore_1
      10: aload_1
      11: iconst_0
      12: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: checkcast     #27                 // class java/lang/Number
      20: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      23: istore_2
      24: aload_1
      25: iconst_1
      26: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #27                 // class java/lang/Number
      34: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      37: istore_3
      38: iload_3
      39: iconst_2
      40: idiv
      41: istore        4
      43: new           #33                 // class kotlin/ranges/IntRange
      46: dup
      47: iconst_1
      48: iload_3
      49: invokespecial #37                 // Method kotlin/ranges/IntRange."<init>":(II)V
      52: astore        5
      54: iload_3
      55: iconst_1
      56: iadd
      57: istore        7
      59: new           #39                 // class java/util/ArrayList
      62: dup
      63: iload         7
      65: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
      68: astore        8
      70: iconst_0
      71: istore        9
      73: iload         9
      75: iload         7
      77: if_icmpge     148
      80: iload         9
      82: istore        10
      84: aload         8
      86: iload         10
      88: istore        11
      90: astore        33
      92: iconst_0
      93: istore        12
      95: iconst_0
      96: istore        13
      98: iload         11
     100: iconst_1
     101: iadd
     102: istore        14
     104: iload         14
     106: newarray       long
     108: astore        15
     110: iload         13
     112: iload         14
     114: if_icmpge     133
     117: iload         13
     119: istore        16
     121: aload         15
     123: iload         16
     125: lconst_1
     126: lastore
     127: iinc          13, 1
     130: goto          110
     133: aload         15
     135: aload         33
     137: swap
     138: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     141: pop
     142: iinc          9, 1
     145: goto          73
     148: aload         8
     150: checkcast     #21                 // class java/util/List
     153: astore        6
     155: iconst_2
     156: istore        7
     158: iload         7
     160: iload_3
     161: if_icmpgt     244
     164: iconst_1
     165: istore        8
     167: iload         8
     169: iload         7
     171: if_icmpge     232
     174: aload         6
     176: iload         7
     178: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #48                 // class "[J"
     186: iload         8
     188: aload         6
     190: iload         7
     192: iconst_1
     193: isub
     194: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     199: checkcast     #48                 // class "[J"
     202: iload         8
     204: iconst_1
     205: isub
     206: laload
     207: aload         6
     209: iload         7
     211: iconst_1
     212: isub
     213: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     218: checkcast     #48                 // class "[J"
     221: iload         8
     223: laload
     224: ladd
     225: lastore
     226: iinc          8, 1
     229: goto          167
     232: iload         7
     234: iload_3
     235: if_icmpeq     244
     238: iinc          7, 1
     241: goto          164
     244: iload_3
     245: iconst_1
     246: iadd
     247: istore        8
     249: new           #39                 // class java/util/ArrayList
     252: dup
     253: iload         8
     255: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
     258: astore        9
     260: iconst_0
     261: istore        10
     263: iload         10
     265: iload         8
     267: if_icmpge     443
     270: iload         10
     272: istore        11
     274: aload         9
     276: iload         11
     278: istore        12
     280: astore        33
     282: iconst_0
     283: istore        13
     285: iconst_0
     286: istore        14
     288: iload         12
     290: iconst_1
     291: iadd
     292: istore        15
     294: iload         15
     296: newarray       double
     298: astore        16
     300: iload         14
     302: iload         15
     304: if_icmpge     427
     307: iload         14
     309: istore        17
     311: aload         16
     313: iload         17
     315: iload_3
     316: aload         6
     318: iload         12
     320: iload         17
     322: iload         4
     324: invokestatic  #52                 // Method main$prob:(ILjava/util/List;III)D
     327: aload         5
     329: checkcast     #54                 // class java/lang/Iterable
     332: astore        18
     334: dstore        19
     336: istore        21
     338: astore        22
     340: dconst_0
     341: dstore        23
     343: aload         18
     345: invokeinterface #58,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     350: astore        25
     352: aload         25
     354: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     359: ifeq          407
     362: aload         25
     364: checkcast     #66                 // class kotlin/collections/IntIterator
     367: invokevirtual #69                 // Method kotlin/collections/IntIterator.nextInt:()I
     370: istore        26
     372: dload         23
     374: iload         26
     376: istore        27
     378: dstore        28
     380: iconst_0
     381: istore        30
     383: iload_3
     384: aload         6
     386: iload         12
     388: iload         17
     390: iload         27
     392: invokestatic  #52                 // Method main$prob:(ILjava/util/List;III)D
     395: dstore        31
     397: dload         28
     399: dload         31
     401: dadd
     402: dstore        23
     404: goto          352
     407: dload         23
     409: dstore        28
     411: aload         22
     413: iload         21
     415: dload         19
     417: dload         28
     419: ddiv
     420: dastore
     421: iinc          14, 1
     424: goto          300
     427: aload         16
     429: nop
     430: aload         33
     432: swap
     433: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     436: pop
     437: iinc          10, 1
     440: goto          263
     443: aload         9
     445: checkcast     #21                 // class java/util/List
     448: astore        7
     450: new           #71                 // class java/util/Random
     453: dup
     454: ldc2_w        #72                 // long 566l
     457: invokespecial #76                 // Method java/util/Random."<init>":(J)V
     460: astore        8
     462: iconst_0
     463: istore        9
     465: iload         9
     467: iload_2
     468: if_icmpge     494
     471: iload         9
     473: istore        10
     475: iconst_0
     476: istore        11
     478: iload_3
     479: iload         4
     481: aload         8
     483: aload         7
     485: invokestatic  #80                 // Method main$solve:(IILjava/util/Random;Ljava/util/List;)V
     488: iinc          9, 1
     491: goto          465
     494: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #110                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #114                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: checkcast     #116                // class java/lang/CharSequence
      10: invokestatic  #122                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      13: invokevirtual #125                // Method java/lang/Object.toString:()Ljava/lang/String;
      16: areturn

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

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

  private static final long main$cnk(java.util.List<long[]>, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #48                 // class "[J"
      10: astore_3
      11: iconst_0
      12: iload_2
      13: if_icmpgt     30
      16: iload_2
      17: aload_3
      18: arraylength
      19: if_icmpge     26
      22: iconst_1
      23: goto          31
      26: iconst_0
      27: goto          31
      30: iconst_0
      31: ifeq          40
      34: aload_3
      35: iload_2
      36: laload
      37: goto          48
      40: iload_2
      41: istore        4
      43: iconst_0
      44: istore        5
      46: lconst_0
      47: nop
      48: lreturn

  private static final double main$prob(int, java.util.List<long[]>, int, int, int);
    Code:
       0: dconst_1
       1: aload_1
       2: iload_2
       3: iload_3
       4: invokestatic  #182                // Method main$cnk:(Ljava/util/List;II)J
       7: l2d
       8: dmul
       9: aload_1
      10: iload_0
      11: iload_2
      12: isub
      13: iload         4
      15: iload_3
      16: isub
      17: invokestatic  #182                // Method main$cnk:(Ljava/util/List;II)J
      20: l2d
      21: dmul
      22: aload_1
      23: iload_0
      24: iload         4
      26: invokestatic  #182                // Method main$cnk:(Ljava/util/List;II)J
      29: l2d
      30: ddiv
      31: dreturn

  private static final java.util.List<java.lang.Integer> main$shuffle(int, java.util.Random);
    Code:
       0: iconst_0
       1: iload_0
       2: invokestatic  #193                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
       5: checkcast     #54                 // class java/lang/Iterable
       8: aload_1
       9: invokestatic  #197                // Method kotlin/collections/CollectionsKt.shuffled:(Ljava/lang/Iterable;Ljava/util/Random;)Ljava/util/List;
      12: areturn

  private static final int main$solve$ask(java.util.List<java.lang.Integer>, java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: new           #202                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #205                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #207                // String ?
       9: invokevirtual #211                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: iload_2
      14: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #27                 // class java/lang/Number
      22: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      25: iconst_1
      26: iadd
      27: invokevirtual #214                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      30: bipush        32
      32: invokevirtual #217                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      35: aload_1
      36: iload_2
      37: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #21                 // class java/util/List
      45: iload_3
      46: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      51: checkcast     #27                 // class java/lang/Number
      54: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      57: iconst_1
      58: iadd
      59: invokevirtual #214                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      62: invokevirtual #218                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      65: getstatic     #224                // Field java/lang/System.out:Ljava/io/PrintStream;
      68: swap
      69: invokevirtual #229                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: invokestatic  #231                // Method readInt:()I
      75: ireturn

  private static final void main$solve$answer(java.util.List<java.lang.Integer>, int);
    Code:
       0: new           #202                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #205                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #240                // String !
       9: invokevirtual #211                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: iload_1
      14: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #27                 // class java/lang/Number
      22: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      25: iconst_1
      26: iadd
      27: invokevirtual #214                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      30: invokevirtual #218                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      33: getstatic     #224                // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #229                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: return

  private static final java.lang.Comparable main$solve$lambda$5(java.util.List, int[], int[], java.lang.Integer);
    Code:
       0: aload_0
       1: aload_1
       2: aload_3
       3: invokestatic  #114                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       6: aload_3
       7: invokevirtual #243                // Method java/lang/Integer.intValue:()I
      10: iaload
      11: invokeinterface #25,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #103                // class "[D"
      19: aload_2
      20: aload_3
      21: invokevirtual #243                // Method java/lang/Integer.intValue:()I
      24: iaload
      25: daload
      26: invokestatic  #248                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      29: checkcast     #250                // class java/lang/Comparable
      32: areturn

  private static final java.lang.Comparable main$solve$lambda$6(java.lang.Integer);
    Code:
       0: aload_0
       1: checkcast     #250                // class java/lang/Comparable
       4: areturn

  private static final void main$solve(int, int, java.util.Random, java.util.List<double[]>);
    Code:
       0: iload_0
       1: aload_2
       2: invokestatic  #260                // Method main$shuffle:(ILjava/util/Random;)Ljava/util/List;
       5: astore        4
       7: new           #39                 // class java/util/ArrayList
      10: dup
      11: iload_0
      12: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
      15: astore        6
      17: iconst_0
      18: istore        7
      20: iload         7
      22: iload_0
      23: if_icmpge     59
      26: iload         7
      28: istore        8
      30: aload         6
      32: iload         8
      34: istore        9
      36: astore        11
      38: iconst_0
      39: istore        10
      41: iload_0
      42: aload_2
      43: invokestatic  #260                // Method main$shuffle:(ILjava/util/Random;)Ljava/util/List;
      46: aload         11
      48: swap
      49: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      52: pop
      53: iinc          7, 1
      56: goto          20
      59: aload         6
      61: checkcast     #21                 // class java/util/List
      64: astore        5
      66: iload_0
      67: newarray       int
      69: astore        6
      71: iload_0
      72: newarray       int
      74: astore        7
      76: new           #262                // class java/util/TreeSet
      79: dup
      80: iconst_2
      81: anewarray     #264                // class kotlin/jvm/functions/Function1
      84: astore        9
      86: aload         9
      88: iconst_0
      89: aload_3
      90: aload         6
      92: aload         7
      94: invokedynamic #281,  0            // InvokeDynamic #0:invoke:(Ljava/util/List;[I[I)Lkotlin/jvm/functions/Function1;
      99: aastore
     100: aload         9
     102: iconst_1
     103: invokedynamic #287,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     108: aastore
     109: aload         9
     111: invokestatic  #293                // Method kotlin/comparisons/ComparisonsKt.compareBy:([Lkotlin/jvm/functions/Function1;)Ljava/util/Comparator;
     114: invokespecial #296                // Method java/util/TreeSet."<init>":(Ljava/util/Comparator;)V
     117: astore        8
     119: aload         8
     121: checkcast     #155                // class java/util/Collection
     124: aload         6
     126: invokestatic  #302                // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
     129: checkcast     #54                 // class java/lang/Iterable
     132: invokestatic  #306                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     135: pop
     136: nop
     137: aload         8
     139: invokevirtual #309                // Method java/util/TreeSet.pollLast:()Ljava/lang/Object;
     142: dup
     143: invokestatic  #114                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     146: checkcast     #27                 // class java/lang/Number
     149: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     152: istore        9
     154: aload         7
     156: iload         9
     158: aload         7
     160: iload         9
     162: iaload
     163: aload         4
     165: aload         5
     167: iload         9
     169: aload         6
     171: iload         9
     173: iaload
     174: istore        10
     176: aload         6
     178: iload         9
     180: iload         10
     182: iconst_1
     183: iadd
     184: iastore
     185: iload         10
     187: invokestatic  #311                // Method main$solve$ask:(Ljava/util/List;Ljava/util/List;II)I
     190: iadd
     191: iastore
     192: aload         6
     194: iload         9
     196: iaload
     197: iload_0
     198: if_icmpne     218
     201: aload         7
     203: iload         9
     205: iaload
     206: iload_1
     207: if_icmpne     218
     210: aload         4
     212: iload         9
     214: invokestatic  #313                // Method main$solve$answer:(Ljava/util/List;I)V
     217: return
     218: aload         8
     220: iload         9
     222: invokestatic  #163                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     225: invokevirtual #314                // Method java/util/TreeSet.add:(Ljava/lang/Object;)Z
     228: pop
     229: goto          136
}


package codechef.snackdown2021.preelim

private fun solve(): IntArray {
	val (_, k) = readInts()
	val a = readInts().sorted()
	val b = IntArray(a.size)
	val used = BooleanArray(a.size)
	for (x in a.indices) {
		fun isGood(i: Int): Boolean {
			b[x] = a[i]
			var y = x + 1
			for (j in a.indices) if (!used[j] && j != i) b[y++] = a[j]
			val max = longestNondecreasingSubsequence(b)
			b.reverse(x + 1, b.size)
			val min = longestNondecreasingSubsequence(b)
			return k in min..max
		}
		val i = a.indices.firstOrNull { !used[it] && isGood(it) } ?: return intArrayOf(-1)
		used[i] = true
	}
	return b
}

private fun longestNondecreasingSubsequence(a: IntArray): Int {
	val dp = IntArray(a.size)
	for (i in a.indices) {
		for (j in 0 until i) if (a[j] <= a[i]) dp[i] = maxOf(dp[i], dp[j])
		dp[i]++
	}
	return dp.maxOrNull()!!
}

@Suppress("UNUSED_PARAMETER") // Kotlin 1.2
fun main(args: Array<String>) = repeat(readInt()) { println(solve().joinToString(" ")) }

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

Compiled from "decsubk.kt"
public final class codechef.snackdown2021.preelim.DecsubkKt {
  private static final int[] solve();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: iconst_1
       4: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       9: checkcast     #18                 // class java/lang/Number
      12: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      15: istore_0
      16: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      19: checkcast     #24                 // class java/lang/Iterable
      22: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      25: astore_1
      26: aload_1
      27: invokeinterface #33,  1           // InterfaceMethod java/util/List.size:()I
      32: newarray       int
      34: astore_2
      35: aload_1
      36: invokeinterface #33,  1           // InterfaceMethod java/util/List.size:()I
      41: newarray       boolean
      43: astore_3
      44: iconst_0
      45: istore        4
      47: aload_1
      48: checkcast     #35                 // class java/util/Collection
      51: invokeinterface #36,  1           // InterfaceMethod java/util/Collection.size:()I
      56: istore        5
      58: iload         4
      60: iload         5
      62: if_icmpge     196
      65: aload_1
      66: checkcast     #35                 // class java/util/Collection
      69: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      72: checkcast     #24                 // class java/lang/Iterable
      75: astore        7
      77: iconst_0
      78: istore        8
      80: aload         7
      82: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      87: astore        9
      89: aload         9
      91: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      96: ifeq          155
      99: aload         9
     101: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     106: astore        10
     108: aload         10
     110: checkcast     #18                 // class java/lang/Number
     113: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     116: istore        11
     118: iconst_0
     119: istore        12
     121: aload_3
     122: iload         11
     124: baload
     125: ifne          146
     128: aload_2
     129: iload         4
     131: aload_1
     132: aload_3
     133: iload_0
     134: iload         11
     136: invokestatic  #58                 // Method solve$isGood:([IILjava/util/List;[ZII)Z
     139: ifeq          146
     142: iconst_1
     143: goto          147
     146: iconst_0
     147: ifeq          89
     150: aload         10
     152: goto          156
     155: aconst_null
     156: checkcast     #60                 // class java/lang/Integer
     159: dup
     160: ifnull        169
     163: invokevirtual #61                 // Method java/lang/Integer.intValue:()I
     166: goto          183
     169: pop
     170: iconst_1
     171: newarray       int
     173: astore        7
     175: aload         7
     177: iconst_0
     178: iconst_m1
     179: iastore
     180: aload         7
     182: areturn
     183: istore        6
     185: aload_3
     186: iload         6
     188: iconst_1
     189: bastore
     190: iinc          4, 1
     193: goto          58
     196: aload_2
     197: areturn

  private static final int longestNondecreasingSubsequence(int[]);
    Code:
       0: aload_0
       1: arraylength
       2: newarray       int
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_0
       8: arraylength
       9: istore_3
      10: iload_2
      11: iload_3
      12: if_icmpge     76
      15: iconst_0
      16: istore        4
      18: iload         4
      20: iload_2
      21: if_icmpge     53
      24: aload_0
      25: iload         4
      27: iaload
      28: aload_0
      29: iload_2
      30: iaload
      31: if_icmpgt     47
      34: aload_1
      35: iload_2
      36: aload_1
      37: iload_2
      38: iaload
      39: aload_1
      40: iload         4
      42: iaload
      43: invokestatic  #88                 // Method java/lang/Math.max:(II)I
      46: iastore
      47: iinc          4, 1
      50: goto          18
      53: iload_2
      54: istore        4
      56: aload_1
      57: iload         4
      59: iaload
      60: istore        5
      62: aload_1
      63: iload         4
      65: iload         5
      67: iconst_1
      68: iadd
      69: iastore
      70: iinc          2, 1
      73: goto          10
      76: aload_1
      77: invokestatic  #94                 // Method kotlin/collections/ArraysKt.maxOrNull:([I)Ljava/lang/Integer;
      80: dup
      81: invokestatic  #100                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      84: invokevirtual #61                 // Method java/lang/Integer.intValue:()I
      87: ireturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #107                // String args
       3: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #114                // Method readInt:()I
       9: istore_1
      10: iconst_0
      11: istore_2
      12: iload_2
      13: iload_1
      14: if_icmpge     55
      17: iload_2
      18: istore_3
      19: iconst_0
      20: istore        4
      22: invokestatic  #116                // Method solve:()[I
      25: ldc           #118                // String
      27: checkcast     #120                // class java/lang/CharSequence
      30: aconst_null
      31: aconst_null
      32: iconst_0
      33: aconst_null
      34: aconst_null
      35: bipush        62
      37: aconst_null
      38: invokestatic  #124                // 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;
      41: getstatic     #130                // Field java/lang/System.out:Ljava/io/PrintStream;
      44: swap
      45: invokevirtual #135                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      48: nop
      49: iinc          2, 1
      52: goto          12
      55: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #144                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #100                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: checkcast     #120                // class java/lang/CharSequence
      10: invokestatic  #150                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      13: invokevirtual #153                // Method java/lang/Object.toString:()Ljava/lang/String;
      16: areturn

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

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

  private static final boolean solve$isGood(int[], int, java.util.List<java.lang.Integer>, boolean[], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aload_2
       3: iload         5
       5: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      10: checkcast     #18                 // class java/lang/Number
      13: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      16: iastore
      17: iload_1
      18: iconst_1
      19: iadd
      20: istore        6
      22: iconst_0
      23: istore        7
      25: aload_2
      26: checkcast     #35                 // class java/util/Collection
      29: invokeinterface #36,  1           // InterfaceMethod java/util/Collection.size:()I
      34: istore        8
      36: iload         7
      38: iload         8
      40: if_icmpge     84
      43: aload_3
      44: iload         7
      46: baload
      47: ifne          78
      50: iload         7
      52: iload         5
      54: if_icmpeq     78
      57: aload_0
      58: iload         6
      60: iinc          6, 1
      63: aload_2
      64: iload         7
      66: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      71: checkcast     #18                 // class java/lang/Number
      74: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      77: iastore
      78: iinc          7, 1
      81: goto          36
      84: aload_0
      85: invokestatic  #200                // Method longestNondecreasingSubsequence:([I)I
      88: istore        7
      90: aload_0
      91: iload_1
      92: iconst_1
      93: iadd
      94: aload_0
      95: arraylength
      96: invokestatic  #204                // Method kotlin/collections/ArraysKt.reverse:([III)V
      99: aload_0
     100: invokestatic  #200                // Method longestNondecreasingSubsequence:([I)I
     103: istore        8
     105: iload         8
     107: iload         4
     109: if_icmpgt     127
     112: iload         4
     114: iload         7
     116: if_icmpgt     123
     119: iconst_1
     120: goto          128
     123: iconst_0
     124: goto          128
     127: iconst_0
     128: ireturn
}