package codeforces.round572

private fun solve() {
	val n = readInt()
	val nei = List(n) { mutableListOf<Edge>() }
	repeat(n - 1) {
		val (aInput, bInput, value) = readInts()
		val a = aInput - 1
		val b = bInput - 1
		nei[a].add(Edge(a, b, value))
		nei[b].add(Edge(b, a, value))
	}
	if (nei.any { it.size == 2 }) {
		println("NO")
		return
	}
	println("YES")
	val ans = nei.flatten().filter { it.from < it.to }.flatMap { edge ->
		val a = dfs(edge.from, edge.to, false, nei)
		val b = dfs(edge.from, edge.to, true, nei)
		val c = dfs(edge.to, edge.from, false, nei)
		val d = dfs(edge.to, edge.from, true, nei)
		val halfValue = edge.value / 2
		listOf(
				Edge(a, c, halfValue),
				Edge(b, d, halfValue),
				Edge(a, b, -halfValue),
				Edge(c, d, -halfValue)
		).filter { it.from != it.to }
	}
	println(ans.size)
	for (edge in ans) {
		println("${edge.from + 1} ${edge.to + 1} ${edge.value}")
	}
}

private data class Edge(val from: Int, val to: Int, val value: Int)

private fun dfs(v: Int, p: Int, order: Boolean, nei: List<List<Edge>>): Int {
	if (nei[v].size == 1) return v
	for (edge in (if (order) nei[v] else nei[v].reversed())) {
		val u = edge.to
		if (u == p) continue
		return dfs(u, v, order, nei)
	}
	error("")
}

fun main() {
	val stdStreams = (false to true)
	val isOnlineJudge = System.getProperty("ONLINE_JUDGE") == "true"
	if (!isOnlineJudge) {
		if (!stdStreams.first) System.setIn(java.io.File("input.txt").inputStream())
		if (!stdStreams.second) System.setOut(java.io.PrintStream("output.txt"))
	}
	val tests = if (isOnlineJudge) 1 else readInt()
	repeat(tests) { solve() }
}

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

Compiled from "a2.kt"
public final class codeforces.round572.A2Kt {
  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readInt:()I
       3: istore_0
       4: new           #12                 // class java/util/ArrayList
       7: dup
       8: iload_0
       9: invokespecial #16                 // Method java/util/ArrayList."<init>":(I)V
      12: astore_2
      13: iconst_0
      14: istore_3
      15: iload_3
      16: iload_0
      17: if_icmpge     57
      20: iload_3
      21: istore        4
      23: aload_2
      24: iload         4
      26: istore        5
      28: astore        26
      30: iconst_0
      31: istore        6
      33: new           #12                 // class java/util/ArrayList
      36: dup
      37: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
      40: checkcast     #20                 // class java/util/List
      43: nop
      44: aload         26
      46: swap
      47: invokevirtual #24                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      50: pop
      51: iinc          3, 1
      54: goto          15
      57: aload_2
      58: checkcast     #20                 // class java/util/List
      61: astore_1
      62: iload_0
      63: iconst_1
      64: isub
      65: istore_2
      66: iconst_0
      67: istore_3
      68: iload_3
      69: iload_2
      70: if_icmpge     211
      73: iload_3
      74: istore        4
      76: iconst_0
      77: istore        5
      79: invokestatic  #28                 // Method readInts:()Ljava/util/List;
      82: astore        6
      84: aload         6
      86: iconst_0
      87: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      92: checkcast     #34                 // class java/lang/Number
      95: invokevirtual #37                 // Method java/lang/Number.intValue:()I
      98: istore        7
     100: aload         6
     102: iconst_1
     103: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #34                 // class java/lang/Number
     111: invokevirtual #37                 // Method java/lang/Number.intValue:()I
     114: istore        8
     116: aload         6
     118: iconst_2
     119: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     124: checkcast     #34                 // class java/lang/Number
     127: invokevirtual #37                 // Method java/lang/Number.intValue:()I
     130: istore        9
     132: iload         7
     134: iconst_1
     135: isub
     136: istore        10
     138: iload         8
     140: iconst_1
     141: isub
     142: istore        11
     144: aload_1
     145: iload         10
     147: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     152: checkcast     #20                 // class java/util/List
     155: new           #39                 // class codeforces/round572/Edge
     158: dup
     159: iload         10
     161: iload         11
     163: iload         9
     165: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     168: invokeinterface #43,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     173: pop
     174: aload_1
     175: iload         11
     177: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     182: checkcast     #20                 // class java/util/List
     185: new           #39                 // class codeforces/round572/Edge
     188: dup
     189: iload         11
     191: iload         10
     193: iload         9
     195: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     198: invokeinterface #43,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     203: pop
     204: nop
     205: iinc          3, 1
     208: goto          68
     211: aload_1
     212: checkcast     #45                 // class java/lang/Iterable
     215: astore_2
     216: iconst_0
     217: istore_3
     218: aload_2
     219: instanceof    #47                 // class java/util/Collection
     222: ifeq          241
     225: aload_2
     226: checkcast     #47                 // class java/util/Collection
     229: invokeinterface #51,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     234: ifeq          241
     237: iconst_0
     238: goto          302
     241: aload_2
     242: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     247: astore        4
     249: aload         4
     251: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     256: ifeq          301
     259: aload         4
     261: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     266: astore        5
     268: aload         5
     270: checkcast     #20                 // class java/util/List
     273: astore        6
     275: iconst_0
     276: istore        7
     278: aload         6
     280: invokeinterface #67,  1           // InterfaceMethod java/util/List.size:()I
     285: iconst_2
     286: if_icmpne     293
     289: iconst_1
     290: goto          294
     293: iconst_0
     294: ifeq          249
     297: iconst_1
     298: goto          302
     301: iconst_0
     302: ifeq          315
     305: ldc           #69                 // String NO
     307: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     310: swap
     311: invokevirtual #81                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     314: return
     315: ldc           #83                 // String YES
     317: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     320: swap
     321: invokevirtual #81                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     324: aload_1
     325: checkcast     #45                 // class java/lang/Iterable
     328: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     331: checkcast     #45                 // class java/lang/Iterable
     334: astore_3
     335: iconst_0
     336: istore        4
     338: aload_3
     339: astore        5
     341: new           #12                 // class java/util/ArrayList
     344: dup
     345: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
     348: checkcast     #47                 // class java/util/Collection
     351: astore        6
     353: iconst_0
     354: istore        7
     356: aload         5
     358: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     363: astore        8
     365: aload         8
     367: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     372: ifeq          428
     375: aload         8
     377: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     382: astore        9
     384: aload         9
     386: checkcast     #39                 // class codeforces/round572/Edge
     389: astore        10
     391: iconst_0
     392: istore        11
     394: aload         10
     396: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     399: aload         10
     401: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     404: if_icmpge     411
     407: iconst_1
     408: goto          412
     411: iconst_0
     412: ifeq          365
     415: aload         6
     417: aload         9
     419: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     424: pop
     425: goto          365
     428: aload         6
     430: checkcast     #20                 // class java/util/List
     433: nop
     434: checkcast     #45                 // class java/lang/Iterable
     437: astore_3
     438: nop
     439: iconst_0
     440: istore        4
     442: aload_3
     443: astore        5
     445: new           #12                 // class java/util/ArrayList
     448: dup
     449: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
     452: checkcast     #47                 // class java/util/Collection
     455: astore        6
     457: iconst_0
     458: istore        7
     460: aload         5
     462: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     467: astore        8
     469: aload         8
     471: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     476: ifeq          779
     479: aload         8
     481: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     486: astore        9
     488: aload         9
     490: checkcast     #39                 // class codeforces/round572/Edge
     493: astore        10
     495: iconst_0
     496: istore        11
     498: aload         10
     500: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     503: aload         10
     505: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     508: iconst_0
     509: aload_1
     510: invokestatic  #100                // Method dfs:(IIZLjava/util/List;)I
     513: istore        12
     515: aload         10
     517: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     520: aload         10
     522: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     525: iconst_1
     526: aload_1
     527: invokestatic  #100                // Method dfs:(IIZLjava/util/List;)I
     530: istore        13
     532: aload         10
     534: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     537: aload         10
     539: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     542: iconst_0
     543: aload_1
     544: invokestatic  #100                // Method dfs:(IIZLjava/util/List;)I
     547: istore        14
     549: aload         10
     551: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     554: aload         10
     556: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     559: iconst_1
     560: aload_1
     561: invokestatic  #100                // Method dfs:(IIZLjava/util/List;)I
     564: istore        15
     566: aload         10
     568: invokevirtual #103                // Method codeforces/round572/Edge.getValue:()I
     571: iconst_2
     572: idiv
     573: istore        16
     575: iconst_4
     576: anewarray     #39                 // class codeforces/round572/Edge
     579: astore        17
     581: aload         17
     583: iconst_0
     584: new           #39                 // class codeforces/round572/Edge
     587: dup
     588: iload         12
     590: iload         14
     592: iload         16
     594: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     597: aastore
     598: aload         17
     600: iconst_1
     601: new           #39                 // class codeforces/round572/Edge
     604: dup
     605: iload         13
     607: iload         15
     609: iload         16
     611: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     614: aastore
     615: aload         17
     617: iconst_2
     618: new           #39                 // class codeforces/round572/Edge
     621: dup
     622: iload         12
     624: iload         13
     626: iload         16
     628: ineg
     629: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     632: aastore
     633: aload         17
     635: iconst_3
     636: new           #39                 // class codeforces/round572/Edge
     639: dup
     640: iload         14
     642: iload         15
     644: iload         16
     646: ineg
     647: invokespecial #42                 // Method codeforces/round572/Edge."<init>":(III)V
     650: aastore
     651: aload         17
     653: invokestatic  #107                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     656: checkcast     #45                 // class java/lang/Iterable
     659: astore        17
     661: nop
     662: iconst_0
     663: istore        18
     665: aload         17
     667: astore        19
     669: new           #12                 // class java/util/ArrayList
     672: dup
     673: invokespecial #18                 // Method java/util/ArrayList."<init>":()V
     676: checkcast     #47                 // class java/util/Collection
     679: astore        20
     681: iconst_0
     682: istore        21
     684: aload         19
     686: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     691: astore        22
     693: aload         22
     695: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     700: ifeq          756
     703: aload         22
     705: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     710: astore        23
     712: aload         23
     714: checkcast     #39                 // class codeforces/round572/Edge
     717: astore        24
     719: iconst_0
     720: istore        25
     722: aload         24
     724: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     727: aload         24
     729: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     732: if_icmpeq     739
     735: iconst_1
     736: goto          740
     739: iconst_0
     740: ifeq          693
     743: aload         20
     745: aload         23
     747: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     752: pop
     753: goto          693
     756: aload         20
     758: checkcast     #20                 // class java/util/List
     761: nop
     762: checkcast     #45                 // class java/lang/Iterable
     765: nop
     766: astore        10
     768: aload         6
     770: aload         10
     772: invokestatic  #111                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     775: pop
     776: goto          469
     779: aload         6
     781: checkcast     #20                 // class java/util/List
     784: nop
     785: astore_2
     786: aload_2
     787: invokeinterface #67,  1           // InterfaceMethod java/util/List.size:()I
     792: istore_3
     793: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     796: iload_3
     797: invokevirtual #113                // Method java/io/PrintStream.println:(I)V
     800: aload_2
     801: invokeinterface #114,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     806: astore_3
     807: aload_3
     808: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     813: ifeq          885
     816: aload_3
     817: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     822: checkcast     #39                 // class codeforces/round572/Edge
     825: astore        4
     827: new           #116                // class java/lang/StringBuilder
     830: dup
     831: invokespecial #117                // Method java/lang/StringBuilder."<init>":()V
     834: aload         4
     836: invokevirtual #92                 // Method codeforces/round572/Edge.getFrom:()I
     839: iconst_1
     840: iadd
     841: invokevirtual #121                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     844: bipush        32
     846: invokevirtual #124                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     849: aload         4
     851: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
     854: iconst_1
     855: iadd
     856: invokevirtual #121                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     859: bipush        32
     861: invokevirtual #124                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     864: aload         4
     866: invokevirtual #103                // Method codeforces/round572/Edge.getValue:()I
     869: invokevirtual #121                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     872: invokevirtual #128                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     875: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     878: swap
     879: invokevirtual #81                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     882: goto          807
     885: return

  private static final int dfs(int, int, boolean, java.util.List<? extends java.util.List<codeforces.round572.Edge>>);
    Code:
       0: aload_3
       1: iload_0
       2: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #20                 // class java/util/List
      10: invokeinterface #67,  1           // InterfaceMethod java/util/List.size:()I
      15: iconst_1
      16: if_icmpne     21
      19: iload_0
      20: ireturn
      21: iload_2
      22: ifeq          38
      25: aload_3
      26: iload_0
      27: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      32: checkcast     #20                 // class java/util/List
      35: goto          51
      38: aload_3
      39: iload_0
      40: invokeinterface #32,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #45                 // class java/lang/Iterable
      48: invokestatic  #171                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      51: invokeinterface #114,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      56: astore        4
      58: aload         4
      60: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          102
      68: aload         4
      70: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: checkcast     #39                 // class codeforces/round572/Edge
      78: astore        5
      80: aload         5
      82: invokevirtual #95                 // Method codeforces/round572/Edge.getTo:()I
      85: istore        6
      87: iload         6
      89: iload_1
      90: if_icmpeq     58
      93: iload         6
      95: iload_0
      96: iload_2
      97: aload_3
      98: invokestatic  #100                // Method dfs:(IIZLjava/util/List;)I
     101: ireturn
     102: new           #173                // class java/lang/IllegalStateException
     105: dup
     106: ldc           #175                // String
     108: invokevirtual #176                // Method java/lang/Object.toString:()Ljava/lang/String;
     111: invokespecial #179                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     114: athrow

  public static final void main();
    Code:
       0: iconst_0
       1: invokestatic  #191                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
       4: iconst_1
       5: invokestatic  #191                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
       8: invokestatic  #197                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      11: astore_0
      12: ldc           #199                // String ONLINE_JUDGE
      14: invokestatic  #203                // Method java/lang/System.getProperty:(Ljava/lang/String;)Ljava/lang/String;
      17: ldc           #205                // String true
      19: invokestatic  #211                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      22: istore_1
      23: iload_1
      24: ifne          87
      27: aload_0
      28: invokevirtual #216                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      31: checkcast     #187                // class java/lang/Boolean
      34: invokevirtual #219                // Method java/lang/Boolean.booleanValue:()Z
      37: ifne          62
      40: new           #221                // class java/io/FileInputStream
      43: dup
      44: new           #223                // class java/io/File
      47: dup
      48: ldc           #225                // String input.txt
      50: invokespecial #226                // Method java/io/File."<init>":(Ljava/lang/String;)V
      53: invokespecial #229                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      56: checkcast     #231                // class java/io/InputStream
      59: invokestatic  #235                // Method java/lang/System.setIn:(Ljava/io/InputStream;)V
      62: aload_0
      63: invokevirtual #238                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      66: checkcast     #187                // class java/lang/Boolean
      69: invokevirtual #219                // Method java/lang/Boolean.booleanValue:()Z
      72: ifne          87
      75: new           #77                 // class java/io/PrintStream
      78: dup
      79: ldc           #240                // String output.txt
      81: invokespecial #241                // Method java/io/PrintStream."<init>":(Ljava/lang/String;)V
      84: invokestatic  #245                // Method java/lang/System.setOut:(Ljava/io/PrintStream;)V
      87: iload_1
      88: ifeq          95
      91: iconst_1
      92: goto          98
      95: invokestatic  #10                 // Method readInt:()I
      98: istore_2
      99: iconst_0
     100: istore_3
     101: iload_3
     102: iload_2
     103: if_icmpge     121
     106: iload_3
     107: istore        4
     109: iconst_0
     110: istore        5
     112: invokestatic  #247                // Method solve:()V
     115: iinc          3, 1
     118: goto          101
     121: return

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

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

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

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

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


package codeforces.ozon2020

import kotlin.random.Random

val r = Random(566)

fun main() {
	readLn()
	val a = readStrings().map { it.toLong() }.shuffled(r)
	val toCheck = List(1 shl 6) { a[it % a.size] + r.nextInt(3) - 1 }.toSet()
	val primes = toCheck.flatMap { primes(it) }.toSet().sorted()
	val ans = primes.fold(a.size.toLong()) { best, p ->
		a.foldRight(0L) { v, sum ->
			(sum + if (v <= p) p - v else minOf(v % p, p - v % p))
					.takeIf { it < best } ?: return@foldRight best
		}
	}
	println(ans)
}

private fun primes(v: Long): List<Long> {
	val primes = mutableListOf<Long>()
	var x = v
	for (i in 2..v) {
		if (x < 2) break
		if (i * i > x) {
			primes.add(x)
			break
		}
		while (x % i == 0L) {
			primes.add(i)
			x /= i
		}
	}
	return primes
}

private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")

Compiled from "f.kt"
public final class codeforces.ozon2020.FKt {
  private static final kotlin.random.Random r;

  public static final kotlin.random.Random getR();
    Code:
       0: getstatic     #11                 // Field r:Lkotlin/random/Random;
       3: areturn

  public static final void main();
    Code:
       0: invokestatic  #17                 // Method readLn:()Ljava/lang/String;
       3: pop
       4: invokestatic  #21                 // Method readStrings:()Ljava/util/List;
       7: checkcast     #23                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #25                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #37                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          98
      54: aload         6
      56: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        8
      63: aload         4
      65: aload         8
      67: checkcast     #53                 // class java/lang/String
      70: astore        9
      72: astore        34
      74: iconst_0
      75: istore        11
      77: aload         9
      79: invokestatic  #59                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      82: nop
      83: invokestatic  #63                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      86: aload         34
      88: swap
      89: invokeinterface #67,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      94: pop
      95: goto          44
      98: aload         4
     100: checkcast     #69                 // class java/util/List
     103: nop
     104: checkcast     #23                 // class java/lang/Iterable
     107: getstatic     #11                 // Field r:Lkotlin/random/Random;
     110: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.shuffled:(Ljava/lang/Iterable;Lkotlin/random/Random;)Ljava/util/List;
     113: astore_0
     114: bipush        64
     116: istore_2
     117: new           #25                 // class java/util/ArrayList
     120: dup
     121: iload_2
     122: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
     125: astore_3
     126: iconst_0
     127: istore        4
     129: iload         4
     131: iload_2
     132: if_icmpge     197
     135: iload         4
     137: istore        5
     139: aload_3
     140: iload         5
     142: istore        6
     144: astore        34
     146: iconst_0
     147: istore        8
     149: aload_0
     150: iload         6
     152: aload_0
     153: invokeinterface #77,  1           // InterfaceMethod java/util/List.size:()I
     158: irem
     159: invokeinterface #81,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: checkcast     #83                 // class java/lang/Number
     167: invokevirtual #87                 // Method java/lang/Number.longValue:()J
     170: getstatic     #11                 // Field r:Lkotlin/random/Random;
     173: iconst_3
     174: invokevirtual #93                 // Method kotlin/random/Random.nextInt:(I)I
     177: i2l
     178: ladd
     179: lconst_1
     180: lsub
     181: invokestatic  #63                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     184: aload         34
     186: swap
     187: invokevirtual #94                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     190: pop
     191: iinc          4, 1
     194: goto          129
     197: aload_3
     198: checkcast     #69                 // class java/util/List
     201: checkcast     #23                 // class java/lang/Iterable
     204: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     207: astore_1
     208: aload_1
     209: checkcast     #23                 // class java/lang/Iterable
     212: astore_3
     213: iconst_0
     214: istore        4
     216: aload_3
     217: astore        5
     219: new           #25                 // class java/util/ArrayList
     222: dup
     223: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     226: checkcast     #37                 // class java/util/Collection
     229: astore        6
     231: iconst_0
     232: istore        8
     234: aload         5
     236: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     241: astore        9
     243: aload         9
     245: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     250: ifeq          296
     253: aload         9
     255: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     260: astore        11
     262: aload         11
     264: checkcast     #83                 // class java/lang/Number
     267: invokevirtual #87                 // Method java/lang/Number.longValue:()J
     270: lstore        12
     272: iconst_0
     273: istore        14
     275: lload         12
     277: invokestatic  #104                // Method primes:(J)Ljava/util/List;
     280: checkcast     #23                 // class java/lang/Iterable
     283: astore        15
     285: aload         6
     287: aload         15
     289: invokestatic  #108                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     292: pop
     293: goto          243
     296: aload         6
     298: checkcast     #69                 // class java/util/List
     301: nop
     302: checkcast     #23                 // class java/lang/Iterable
     305: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     308: checkcast     #23                 // class java/lang/Iterable
     311: invokestatic  #112                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     314: astore_2
     315: aload_2
     316: checkcast     #23                 // class java/lang/Iterable
     319: astore        5
     321: aload_0
     322: invokeinterface #77,  1           // InterfaceMethod java/util/List.size:()I
     327: i2l
     328: lstore        6
     330: iconst_0
     331: istore        8
     333: lload         6
     335: lstore        9
     337: aload         5
     339: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     344: astore        11
     346: aload         11
     348: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     353: ifeq          554
     356: aload         11
     358: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     363: astore        12
     365: lload         9
     367: aload         12
     369: checkcast     #83                 // class java/lang/Number
     372: invokevirtual #87                 // Method java/lang/Number.longValue:()J
     375: lstore        13
     377: lstore        15
     379: iconst_0
     380: istore        17
     382: aload_0
     383: astore        18
     385: lconst_0
     386: lstore        19
     388: iconst_0
     389: istore        21
     391: lload         19
     393: lstore        22
     395: aload         18
     397: invokeinterface #115,  1          // InterfaceMethod java/util/List.isEmpty:()Z
     402: ifne          546
     405: aload         18
     407: aload         18
     409: invokeinterface #77,  1           // InterfaceMethod java/util/List.size:()I
     414: invokeinterface #119,  2          // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
     419: astore        24
     421: aload         24
     423: invokeinterface #124,  1          // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
     428: ifeq          546
     431: aload         24
     433: invokeinterface #127,  1          // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
     438: lload         22
     440: lstore        25
     442: checkcast     #83                 // class java/lang/Number
     445: invokevirtual #87                 // Method java/lang/Number.longValue:()J
     448: lstore        27
     450: iconst_0
     451: istore        29
     453: lload         25
     455: lload         27
     457: lload         13
     459: lcmp
     460: ifgt          471
     463: lload         13
     465: lload         27
     467: lsub
     468: goto          487
     471: lload         27
     473: lload         13
     475: lrem
     476: lload         13
     478: lload         27
     480: lload         13
     482: lrem
     483: lsub
     484: invokestatic  #133                // Method java/lang/Math.min:(JJ)J
     487: ladd
     488: invokestatic  #63                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     491: astore        30
     493: aload         30
     495: checkcast     #83                 // class java/lang/Number
     498: invokevirtual #87                 // Method java/lang/Number.longValue:()J
     501: lstore        31
     503: iconst_0
     504: istore        33
     506: lload         31
     508: lload         15
     510: lcmp
     511: ifge          518
     514: iconst_1
     515: goto          519
     518: iconst_0
     519: ifeq          527
     522: aload         30
     524: goto          528
     527: aconst_null
     528: dup
     529: ifnull        538
     532: invokevirtual #134                // Method java/lang/Long.longValue:()J
     535: goto          541
     538: pop
     539: lload         15
     541: lstore        22
     543: goto          421
     546: lload         22
     548: nop
     549: lstore        9
     551: goto          346
     554: lload         9
     556: lstore_3
     557: getstatic     #140                // Field java/lang/System.out:Ljava/io/PrintStream;
     560: lload_3
     561: invokevirtual #146                // Method java/io/PrintStream.println:(J)V
     564: return

  private static final java.util.List<java.lang.Long> primes(long);
    Code:
       0: new           #25                 // class java/util/ArrayList
       3: dup
       4: invokespecial #100                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #69                 // class java/util/List
      10: astore_2
      11: lload_0
      12: lstore_3
      13: ldc2_w        #193                // long 2l
      16: lstore        5
      18: lload         5
      20: lload_0
      21: lcmp
      22: ifgt          102
      25: lload_3
      26: ldc2_w        #193                // long 2l
      29: lcmp
      30: iflt          102
      33: lload         5
      35: lload         5
      37: lmul
      38: lload_3
      39: lcmp
      40: ifle          57
      43: aload_2
      44: lload_3
      45: invokestatic  #63                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      48: invokeinterface #195,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      53: pop
      54: goto          102
      57: lload_3
      58: lload         5
      60: lrem
      61: lconst_0
      62: lcmp
      63: ifne          86
      66: aload_2
      67: lload         5
      69: invokestatic  #63                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      72: invokeinterface #195,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      77: pop
      78: lload_3
      79: lload         5
      81: ldiv
      82: lstore_3
      83: goto          57
      86: lload         5
      88: lload_0
      89: lcmp
      90: ifeq          102
      93: lload         5
      95: lconst_1
      96: ladd
      97: lstore        5
      99: goto          25
     102: aload_2
     103: areturn

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

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

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

  static {};
    Code:
       0: sipush        566
       3: invokestatic  #231                // Method kotlin/random/RandomKt.Random:(I)Lkotlin/random/Random;
       6: putstatic     #11                 // Field r:Lkotlin/random/Random;
       9: return
}


package codeforces.kotlinheroes3

private fun solve() {
	val s = readLn()
	val inf = (s.maxOrNull()!! + 1).toString()
	val init = listOf(listOf(inf to listOf<Boolean>()), listOf("" to listOf()))
	val ans = s.foldIndexed(init) { i, (sure, unsure), c ->
		val next = List(2) { MutableList(i + 1) { inf to listOf<Boolean>()} }
		fun update(isSure: Boolean, index: Int, new: Pair<String, List<Boolean>>) {
			val a = next[if (isSure) 0 else 1]
			if (!new.first.startsWith(inf) && new.first < a[index].first) a[index] = new
		}
		sure.forEachIndexed { j, (t, how) ->
			val storeShort = if (t.length == j) 1 else 0
			update(true, j + 1 - storeShort, t to how + false)
			update(true, minOf(j + storeShort, i - j), t + c to how + true)
		}
		unsure.forEachIndexed { j, (t, how) ->
			update(false, j, t + c to how + true)
			if (j != i - j && t != inf) when {
				c > t[j] -> update(true, j + 1, t.substring(0, j) + c to how + true)
				else -> update(c < t[j], j + 1, t to how + false)
			}
		}
		next
	}
	println(ans.flatten().minByOrNull { it.first }!!.second.joinToString("") { if (it) "R" else "B" })
}

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

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

Compiled from "h.kt"
public final class codeforces.kotlinheroes3.HKt {
  private static final void solve();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: astore_0
       4: aload_0
       5: checkcast     #12                 // class java/lang/CharSequence
       8: invokestatic  #18                 // Method kotlin/text/StringsKt.maxOrNull:(Ljava/lang/CharSequence;)Ljava/lang/Character;
      11: dup
      12: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      15: invokevirtual #30                 // Method java/lang/Character.charValue:()C
      18: iconst_1
      19: iadd
      20: i2c
      21: invokestatic  #36                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      24: astore_1
      25: iconst_2
      26: anewarray     #38                 // class java/util/List
      29: astore_3
      30: aload_3
      31: iconst_0
      32: aload_1
      33: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      36: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      39: invokestatic  #54                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      42: aastore
      43: aload_3
      44: iconst_1
      45: ldc           #56                 // String
      47: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      50: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      53: invokestatic  #54                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      56: aastore
      57: aload_3
      58: invokestatic  #59                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      61: astore_2
      62: aload_0
      63: checkcast     #12                 // class java/lang/CharSequence
      66: astore        4
      68: iconst_0
      69: istore        5
      71: iconst_0
      72: istore        6
      74: aload_2
      75: astore        7
      77: iconst_0
      78: istore        8
      80: iload         8
      82: aload         4
      84: invokeinterface #63,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      89: if_icmpge     765
      92: aload         4
      94: iload         8
      96: invokeinterface #67,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     101: istore        9
     103: iload         6
     105: iinc          6, 1
     108: aload         7
     110: iload         9
     112: istore        10
     114: astore        11
     116: istore        12
     118: iconst_0
     119: istore        13
     121: aload         11
     123: iconst_0
     124: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #38                 // class java/util/List
     132: astore        14
     134: aload         11
     136: iconst_1
     137: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #38                 // class java/util/List
     145: astore        15
     147: iconst_2
     148: istore        16
     150: new           #73                 // class java/util/ArrayList
     153: dup
     154: iload         16
     156: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     159: astore        17
     161: iconst_0
     162: istore        18
     164: iload         18
     166: iload         16
     168: if_icmpge     267
     171: iload         18
     173: istore        19
     175: aload         17
     177: iload         19
     179: istore        20
     181: astore        21
     183: iconst_0
     184: istore        22
     186: iload         12
     188: iconst_1
     189: iadd
     190: istore        23
     192: new           #73                 // class java/util/ArrayList
     195: dup
     196: iload         23
     198: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     201: astore        24
     203: iconst_0
     204: istore        25
     206: iload         25
     208: iload         23
     210: if_icmpge     248
     213: iload         25
     215: istore        26
     217: aload         24
     219: iload         26
     221: istore        27
     223: astore        28
     225: iconst_0
     226: istore        29
     228: aload_1
     229: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     232: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     235: aload         28
     237: swap
     238: invokevirtual #81                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     241: pop
     242: iinc          25, 1
     245: goto          206
     248: aload         24
     250: checkcast     #38                 // class java/util/List
     253: nop
     254: aload         21
     256: swap
     257: invokevirtual #81                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     260: pop
     261: iinc          18, 1
     264: goto          164
     267: aload         17
     269: checkcast     #38                 // class java/util/List
     272: astore        30
     274: aload         14
     276: checkcast     #83                 // class java/lang/Iterable
     279: astore        16
     281: iconst_0
     282: istore        17
     284: iconst_0
     285: istore        18
     287: aload         16
     289: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     294: astore        19
     296: aload         19
     298: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     303: ifeq          472
     306: aload         19
     308: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     313: astore        20
     315: iload         18
     317: iinc          18, 1
     320: istore        22
     322: iload         22
     324: ifge          330
     327: invokestatic  #100                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     330: iload         22
     332: aload         20
     334: checkcast     #102                // class kotlin/Pair
     337: astore        23
     339: istore        24
     341: iconst_0
     342: istore        25
     344: aload         23
     346: invokevirtual #105                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     349: checkcast     #32                 // class java/lang/String
     352: astore        26
     354: aload         23
     356: invokevirtual #108                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     359: checkcast     #38                 // class java/util/List
     362: astore        27
     364: aload         26
     366: invokevirtual #109                // Method java/lang/String.length:()I
     369: iload         24
     371: if_icmpne     378
     374: iconst_1
     375: goto          379
     378: iconst_0
     379: istore        28
     381: aload         30
     383: aload_1
     384: iconst_1
     385: iload         24
     387: iconst_1
     388: iadd
     389: iload         28
     391: isub
     392: aload         26
     394: aload         27
     396: checkcast     #111                // class java/util/Collection
     399: iconst_0
     400: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     403: invokestatic  #120                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     406: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     409: invokestatic  #124                // Method solve$lambda$4$update:(Ljava/util/List;Ljava/lang/String;ZILkotlin/Pair;)V
     412: aload         30
     414: aload_1
     415: iconst_1
     416: iload         24
     418: iload         28
     420: iadd
     421: iload         12
     423: iload         24
     425: isub
     426: invokestatic  #130                // Method java/lang/Math.min:(II)I
     429: new           #132                // class java/lang/StringBuilder
     432: dup
     433: invokespecial #134                // Method java/lang/StringBuilder."<init>":()V
     436: aload         26
     438: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     441: iload         10
     443: invokevirtual #141                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     446: invokevirtual #144                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     449: aload         27
     451: checkcast     #111                // class java/util/Collection
     454: iconst_1
     455: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     458: invokestatic  #120                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     461: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     464: invokestatic  #124                // Method solve$lambda$4$update:(Ljava/util/List;Ljava/lang/String;ZILkotlin/Pair;)V
     467: nop
     468: nop
     469: goto          296
     472: nop
     473: aload         15
     475: checkcast     #83                 // class java/lang/Iterable
     478: astore        16
     480: iconst_0
     481: istore        17
     483: iconst_0
     484: istore        18
     486: aload         16
     488: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     493: astore        19
     495: aload         19
     497: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     502: ifeq          754
     505: aload         19
     507: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     512: astore        20
     514: iload         18
     516: iinc          18, 1
     519: istore        22
     521: iload         22
     523: ifge          529
     526: invokestatic  #100                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     529: iload         22
     531: aload         20
     533: checkcast     #102                // class kotlin/Pair
     536: astore        23
     538: istore        24
     540: iconst_0
     541: istore        25
     543: aload         23
     545: invokevirtual #105                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     548: checkcast     #32                 // class java/lang/String
     551: astore        26
     553: aload         23
     555: invokevirtual #108                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     558: checkcast     #38                 // class java/util/List
     561: astore        27
     563: aload         30
     565: aload_1
     566: iconst_0
     567: iload         24
     569: new           #132                // class java/lang/StringBuilder
     572: dup
     573: invokespecial #134                // Method java/lang/StringBuilder."<init>":()V
     576: aload         26
     578: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     581: iload         10
     583: invokevirtual #141                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     586: invokevirtual #144                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     589: aload         27
     591: checkcast     #111                // class java/util/Collection
     594: iconst_1
     595: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     598: invokestatic  #120                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     601: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     604: invokestatic  #124                // Method solve$lambda$4$update:(Ljava/util/List;Ljava/lang/String;ZILkotlin/Pair;)V
     607: iload         24
     609: iload         12
     611: iload         24
     613: isub
     614: if_icmpeq     749
     617: aload         26
     619: aload_1
     620: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     623: ifne          749
     626: iload         10
     628: aload         26
     630: iload         24
     632: invokevirtual #149                // Method java/lang/String.charAt:(I)C
     635: invokestatic  #152                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     638: ifle          702
     641: aload         30
     643: aload_1
     644: iconst_1
     645: iload         24
     647: iconst_1
     648: iadd
     649: new           #132                // class java/lang/StringBuilder
     652: dup
     653: invokespecial #134                // Method java/lang/StringBuilder."<init>":()V
     656: aload         26
     658: iconst_0
     659: iload         24
     661: invokevirtual #156                // Method java/lang/String.substring:(II)Ljava/lang/String;
     664: dup
     665: ldc           #158                // String substring(...)
     667: invokestatic  #162                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     670: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     673: iload         10
     675: invokevirtual #141                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     678: invokevirtual #144                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     681: aload         27
     683: checkcast     #111                // class java/util/Collection
     686: iconst_1
     687: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     690: invokestatic  #120                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     693: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     696: invokestatic  #124                // Method solve$lambda$4$update:(Ljava/util/List;Ljava/lang/String;ZILkotlin/Pair;)V
     699: goto          749
     702: aload         30
     704: aload_1
     705: iload         10
     707: aload         26
     709: iload         24
     711: invokevirtual #149                // Method java/lang/String.charAt:(I)C
     714: invokestatic  #152                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     717: ifge          724
     720: iconst_1
     721: goto          725
     724: iconst_0
     725: iload         24
     727: iconst_1
     728: iadd
     729: aload         26
     731: aload         27
     733: checkcast     #111                // class java/util/Collection
     736: iconst_0
     737: invokestatic  #116                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     740: invokestatic  #120                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     743: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     746: invokestatic  #124                // Method solve$lambda$4$update:(Ljava/util/List;Ljava/lang/String;ZILkotlin/Pair;)V
     749: nop
     750: nop
     751: goto          495
     754: nop
     755: aload         30
     757: astore        7
     759: iinc          8, 1
     762: goto          80
     765: aload         7
     767: astore_3
     768: aload_3
     769: checkcast     #83                 // class java/lang/Iterable
     772: invokestatic  #166                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     775: checkcast     #83                 // class java/lang/Iterable
     778: astore        4
     780: iconst_0
     781: istore        5
     783: aload         4
     785: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     790: astore        6
     792: aload         6
     794: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     799: ifne          806
     802: aconst_null
     803: goto          917
     806: aload         6
     808: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     813: astore        7
     815: aload         6
     817: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     822: ifne          830
     825: aload         7
     827: goto          917
     830: aload         7
     832: checkcast     #102                // class kotlin/Pair
     835: astore        8
     837: iconst_0
     838: istore        9
     840: aload         8
     842: invokevirtual #169                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     845: checkcast     #32                 // class java/lang/String
     848: checkcast     #171                // class java/lang/Comparable
     851: astore        8
     853: aload         6
     855: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     860: astore        9
     862: aload         9
     864: checkcast     #102                // class kotlin/Pair
     867: astore        10
     869: iconst_0
     870: istore        11
     872: aload         10
     874: invokevirtual #169                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     877: checkcast     #32                 // class java/lang/String
     880: checkcast     #171                // class java/lang/Comparable
     883: astore        10
     885: aload         8
     887: aload         10
     889: invokeinterface #175,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     894: ifle          905
     897: aload         9
     899: astore        7
     901: aload         10
     903: astore        8
     905: aload         6
     907: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     912: ifne          853
     915: aload         7
     917: dup
     918: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     921: checkcast     #102                // class kotlin/Pair
     924: invokevirtual #178                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     927: checkcast     #83                 // class java/lang/Iterable
     930: ldc           #56                 // String
     932: checkcast     #12                 // class java/lang/CharSequence
     935: aconst_null
     936: aconst_null
     937: iconst_0
     938: aconst_null
     939: invokedynamic #198,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     944: bipush        30
     946: aconst_null
     947: invokestatic  #202                // 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;
     950: getstatic     #208                // Field java/lang/System.out:Ljava/io/PrintStream;
     953: swap
     954: invokevirtual #213                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     957: return

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

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

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

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

  private static final void solve$lambda$4$update(java.util.List<? extends java.util.List<kotlin.Pair<java.lang.String, java.util.List<java.lang.Boolean>>>>, java.lang.String, boolean, int, kotlin.Pair<java.lang.String, ? extends java.util.List<java.lang.Boolean>>);
    Code:
       0: aload_0
       1: iload_2
       2: ifeq          9
       5: iconst_0
       6: goto          10
       9: iconst_1
      10: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      15: checkcast     #38                 // class java/util/List
      18: astore        5
      20: aload         4
      22: invokevirtual #169                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      25: checkcast     #32                 // class java/lang/String
      28: aload_1
      29: iconst_0
      30: iconst_2
      31: aconst_null
      32: invokestatic  #287                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      35: ifne          80
      38: aload         4
      40: invokevirtual #169                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      43: checkcast     #32                 // class java/lang/String
      46: aload         5
      48: iload_3
      49: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      54: checkcast     #102                // class kotlin/Pair
      57: invokevirtual #169                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      60: checkcast     #32                 // class java/lang/String
      63: invokevirtual #289                // Method java/lang/String.compareTo:(Ljava/lang/String;)I
      66: ifge          80
      69: aload         5
      71: iload_3
      72: aload         4
      74: invokeinterface #293,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      79: pop
      80: return

  private static final java.lang.CharSequence solve$lambda$6(boolean);
    Code:
       0: iload_0
       1: ifeq          13
       4: ldc_w         #300                // String R
       7: checkcast     #12                 // class java/lang/CharSequence
      10: goto          19
      13: ldc_w         #302                // String B
      16: checkcast     #12                 // class java/lang/CharSequence
      19: areturn
}


package codeforces.kotlinheroes3

private fun solve() {
	val (n, m) = readInts()
	data class Segment(val start: Int, val end: Int, val id: Int)
	val segments = List(n) { val data = readInts(); Segment(data[0], data[1], it) }
	val byOpening = segments.sortedByDescending { it.start }.toMutableList()
	val ans = MutableList(n) { 0 }
	val byEnding = sortedSetOf<Segment>(compareBy({ it.end }, { it.id }))
	var time = 0
	var worstGap = 0
	while (true) {
		if (byEnding.isEmpty()) time = byOpening.lastOrNull()?.start ?: break
		while (byOpening.lastOrNull()?.start == time) byEnding.add(byOpening.removeAt(byOpening.lastIndex))
		for (temp in 0 until m) {
			val segment = byEnding.pollFirst() ?: break
			worstGap = maxOf(worstGap, time - segment.end)
			ans[segment.id] = time
		}
		time++
	}
	println(worstGap)
	println(ans.joinToString(" "))
}

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

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

Compiled from "Comparisons.kt"
public final class codeforces.kotlinheroes3.FKt$solve$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public codeforces.kotlinheroes3.FKt$solve$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

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

Compiled from "f.kt"
public final class codeforces.kotlinheroes3.FKt {
  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     121
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        11
      63: iconst_0
      64: istore        8
      66: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      69: astore        9
      71: new           #30                 // class codeforces/kotlinheroes3/FKt$solve$Segment
      74: dup
      75: aload         9
      77: iconst_0
      78: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      83: checkcast     #18                 // class java/lang/Number
      86: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      89: aload         9
      91: iconst_1
      92: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #18                 // class java/lang/Number
     100: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     103: iload         7
     105: invokespecial #33                 // Method codeforces/kotlinheroes3/FKt$solve$Segment."<init>":(III)V
     108: aload         11
     110: swap
     111: invokevirtual #37                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     114: pop
     115: iinc          5, 1
     118: goto          45
     121: aload         4
     123: checkcast     #12                 // class java/util/List
     126: astore_3
     127: aload_3
     128: checkcast     #39                 // class java/lang/Iterable
     131: astore        5
     133: iconst_0
     134: istore        6
     136: aload         5
     138: new           #41                 // class codeforces/kotlinheroes3/FKt$solve$$inlined$sortedByDescending$1
     141: dup
     142: invokespecial #43                 // Method codeforces/kotlinheroes3/FKt$solve$$inlined$sortedByDescending$1."<init>":()V
     145: checkcast     #45                 // class java/util/Comparator
     148: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     151: checkcast     #53                 // class java/util/Collection
     154: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     157: astore        4
     159: new           #24                 // class java/util/ArrayList
     162: dup
     163: iload_1
     164: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     167: astore        6
     169: iconst_0
     170: istore        7
     172: iload         7
     174: iload_1
     175: if_icmpge     210
     178: iload         7
     180: istore        8
     182: aload         6
     184: iload         8
     186: istore        9
     188: astore        11
     190: iconst_0
     191: istore        10
     193: iconst_0
     194: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     197: aload         11
     199: swap
     200: invokevirtual #37                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     203: pop
     204: iinc          7, 1
     207: goto          172
     210: aload         6
     212: checkcast     #12                 // class java/util/List
     215: astore        5
     217: iconst_2
     218: anewarray     #65                 // class kotlin/jvm/functions/Function1
     221: astore        7
     223: aload         7
     225: iconst_0
     226: invokedynamic #84,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     231: aastore
     232: aload         7
     234: iconst_1
     235: invokedynamic #89,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     240: aastore
     241: aload         7
     243: invokestatic  #95                 // Method kotlin/comparisons/ComparisonsKt.compareBy:([Lkotlin/jvm/functions/Function1;)Ljava/util/Comparator;
     246: iconst_0
     247: anewarray     #30                 // class codeforces/kotlinheroes3/FKt$solve$Segment
     250: invokestatic  #101                // Method kotlin/collections/SetsKt.sortedSetOf:(Ljava/util/Comparator;[Ljava/lang/Object;)Ljava/util/TreeSet;
     253: astore        6
     255: iconst_0
     256: istore        7
     258: iconst_0
     259: istore        8
     261: nop
     262: aload         6
     264: invokevirtual #107                // Method java/util/TreeSet.isEmpty:()Z
     267: ifeq          294
     270: aload         4
     272: invokestatic  #111                // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;
     275: checkcast     #30                 // class codeforces/kotlinheroes3/FKt$solve$Segment
     278: dup
     279: ifnull        288
     282: invokevirtual #114                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getStart:()I
     285: goto          292
     288: pop
     289: goto          420
     292: istore        7
     294: aload         4
     296: invokestatic  #111                // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;
     299: checkcast     #30                 // class codeforces/kotlinheroes3/FKt$solve$Segment
     302: dup
     303: ifnull        322
     306: invokevirtual #114                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getStart:()I
     309: iload         7
     311: if_icmpne     318
     314: iconst_1
     315: goto          324
     318: iconst_0
     319: goto          324
     322: pop
     323: iconst_0
     324: ifeq          348
     327: aload         6
     329: aload         4
     331: aload         4
     333: invokestatic  #118                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     336: invokeinterface #121,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
     341: invokevirtual #122                // Method java/util/TreeSet.add:(Ljava/lang/Object;)Z
     344: pop
     345: goto          294
     348: iconst_0
     349: istore        9
     351: iload         9
     353: iload_2
     354: if_icmpge     414
     357: aload         6
     359: invokevirtual #126                // Method java/util/TreeSet.pollFirst:()Ljava/lang/Object;
     362: checkcast     #30                 // class codeforces/kotlinheroes3/FKt$solve$Segment
     365: dup
     366: ifnonnull     373
     369: pop
     370: goto          414
     373: astore        10
     375: iload         8
     377: iload         7
     379: aload         10
     381: invokevirtual #129                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getEnd:()I
     384: isub
     385: invokestatic  #135                // Method java/lang/Math.max:(II)I
     388: istore        8
     390: aload         5
     392: aload         10
     394: invokevirtual #138                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getId:()I
     397: iload         7
     399: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     402: invokeinterface #142,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     407: pop
     408: iinc          9, 1
     411: goto          351
     414: iinc          7, 1
     417: goto          261
     420: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
     423: iload         8
     425: invokevirtual #153                // Method java/io/PrintStream.println:(I)V
     428: aload         5
     430: checkcast     #39                 // class java/lang/Iterable
     433: ldc           #155                // String
     435: checkcast     #157                // class java/lang/CharSequence
     438: aconst_null
     439: aconst_null
     440: iconst_0
     441: aconst_null
     442: aconst_null
     443: bipush        62
     445: aconst_null
     446: invokestatic  #161                // 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;
     449: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
     452: swap
     453: invokevirtual #164                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     456: return

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

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

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

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

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

  private static final java.lang.Comparable solve$lambda$3(codeforces.kotlinheroes3.FKt$solve$Segment);
    Code:
       0: aload_0
       1: ldc_w         #256                // String it
       4: invokestatic  #260                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #129                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getEnd:()I
      11: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: checkcast     #262                // class java/lang/Comparable
      17: areturn

  private static final java.lang.Comparable solve$lambda$4(codeforces.kotlinheroes3.FKt$solve$Segment);
    Code:
       0: aload_0
       1: ldc_w         #256                // String it
       4: invokestatic  #260                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #138                // Method codeforces/kotlinheroes3/FKt$solve$Segment.getId:()I
      11: invokestatic  #63                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: checkcast     #262                // class java/lang/Comparable
      17: areturn
}

Compiled from "f.kt"
public final class codeforces.kotlinheroes3.FKt$solve$Segment {
  private final int start;

  private final int end;

  private final int id;

  public codeforces.kotlinheroes3.FKt$solve$Segment(int, int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field start:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field end:I
      14: aload_0
      15: iload_3
      16: putfield      #19                 // Field id:I
      19: return

  public final int getStart();
    Code:
       0: aload_0
       1: getfield      #13                 // Field start:I
       4: ireturn

  public final int getEnd();
    Code:
       0: aload_0
       1: getfield      #16                 // Field end:I
       4: ireturn

  public final int getId();
    Code:
       0: aload_0
       1: getfield      #19                 // Field id:I
       4: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field start:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #16                 // Field end:I
       4: ireturn

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #19                 // Field id:I
       4: ireturn

  public final codeforces.kotlinheroes3.FKt$solve$Segment copy(int, int, int);
    Code:
       0: new           #2                  // class codeforces/kotlinheroes3/FKt$solve$Segment
       3: dup
       4: iload_1
       5: iload_2
       6: iload_3
       7: invokespecial #32                 // Method "<init>":(III)V
      10: areturn

  public static codeforces.kotlinheroes3.FKt$solve$Segment copy$default(codeforces.kotlinheroes3.FKt$solve$Segment, int, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field start:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field end:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #19                 // Field id:I
      35: istore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: iload_3
      40: invokevirtual #36                 // Method copy:(III)Lcodeforces/kotlinheroes3/FKt$solve$Segment;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #40                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #41                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #43                 // String Segment(start=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field start:I
      16: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #52                 // String , end=
      21: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field end:I
      28: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #54                 // String , id=
      33: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #19                 // Field id:I
      40: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #57                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #59                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field start:I
       4: invokestatic  #65                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field end:I
      16: invokestatic  #65                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #19                 // Field id:I
      29: invokestatic  #65                 // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class codeforces/kotlinheroes3/FKt$solve$Segment
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class codeforces/kotlinheroes3/FKt$solve$Segment
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field start:I
      25: aload_2
      26: getfield      #13                 // Field start:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field end:I
      38: aload_2
      39: getfield      #16                 // Field end:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #19                 // Field id:I
      51: aload_2
      52: getfield      #19                 // Field id:I
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: iconst_1
      61: ireturn
}