package yandex.y2023.qual

private fun solve() {
	val (n, m) = readInts()
	val a = readInts()
	val aSorted = a.sorted()
	val y = aSorted[m - 1]
	val yTake = aSorted.take(m).count { it == y }
	val xDefinitely = a.indices.filter { a[it] < y }
	val xY = a.indices.filter { a[it] == y }
	val xLeft = xDefinitely.firstOrNull() ?: n
	val xRight = xDefinitely.lastOrNull() ?: -1
	val ans = (0..(xY.size - yTake)).minOf { i ->
		val xYLeft = xY[i]
		val xYRight = xY[i + yTake - 1]
		maxOf(xYRight, xRight) - minOf(xYLeft, xLeft) + 1
	}
	println(ans)
}

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

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

Compiled from "b.kt"
public final class yandex.y2023.qual.BKt {
  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: invokestatic  #10                 // Method readInts:()Ljava/util/List;
      35: astore_3
      36: aload_3
      37: checkcast     #24                 // class java/lang/Iterable
      40: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      43: astore        4
      45: aload         4
      47: iload_2
      48: iconst_1
      49: isub
      50: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      55: checkcast     #18                 // class java/lang/Number
      58: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      61: istore        5
      63: aload         4
      65: checkcast     #24                 // class java/lang/Iterable
      68: iload_2
      69: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      72: checkcast     #24                 // class java/lang/Iterable
      75: astore        7
      77: iconst_0
      78: istore        8
      80: aload         7
      82: instanceof    #36                 // class java/util/Collection
      85: ifeq          105
      88: aload         7
      90: checkcast     #36                 // class java/util/Collection
      93: invokeinterface #40,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      98: ifeq          105
     101: iconst_0
     102: goto          180
     105: iconst_0
     106: istore        9
     108: aload         7
     110: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     115: astore        10
     117: aload         10
     119: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     124: ifeq          178
     127: aload         10
     129: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     134: astore        11
     136: aload         11
     138: checkcast     #18                 // class java/lang/Number
     141: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     144: istore        12
     146: iconst_0
     147: istore        13
     149: iload         12
     151: iload         5
     153: if_icmpne     160
     156: iconst_1
     157: goto          161
     160: iconst_0
     161: ifeq          117
     164: iinc          9, 1
     167: iload         9
     169: ifge          117
     172: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     175: goto          117
     178: iload         9
     180: istore        6
     182: aload_3
     183: checkcast     #36                 // class java/util/Collection
     186: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     189: checkcast     #24                 // class java/lang/Iterable
     192: astore        8
     194: iconst_0
     195: istore        9
     197: aload         8
     199: astore        10
     201: new           #62                 // class java/util/ArrayList
     204: dup
     205: invokespecial #65                 // Method java/util/ArrayList."<init>":()V
     208: checkcast     #36                 // class java/util/Collection
     211: astore        11
     213: iconst_0
     214: istore        12
     216: aload         10
     218: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     223: astore        13
     225: aload         13
     227: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     232: ifeq          297
     235: aload         13
     237: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     242: astore        14
     244: aload         14
     246: checkcast     #18                 // class java/lang/Number
     249: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     252: istore        15
     254: iconst_0
     255: istore        16
     257: aload_3
     258: iload         15
     260: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     265: checkcast     #18                 // class java/lang/Number
     268: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     271: iload         5
     273: if_icmpge     280
     276: iconst_1
     277: goto          281
     280: iconst_0
     281: ifeq          225
     284: aload         11
     286: aload         14
     288: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     293: pop
     294: goto          225
     297: aload         11
     299: checkcast     #12                 // class java/util/List
     302: nop
     303: astore        7
     305: aload_3
     306: checkcast     #36                 // class java/util/Collection
     309: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     312: checkcast     #24                 // class java/lang/Iterable
     315: astore        9
     317: iconst_0
     318: istore        10
     320: aload         9
     322: astore        11
     324: new           #62                 // class java/util/ArrayList
     327: dup
     328: invokespecial #65                 // Method java/util/ArrayList."<init>":()V
     331: checkcast     #36                 // class java/util/Collection
     334: astore        12
     336: iconst_0
     337: istore        13
     339: aload         11
     341: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     346: astore        14
     348: aload         14
     350: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     355: ifeq          420
     358: aload         14
     360: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     365: astore        15
     367: aload         15
     369: checkcast     #18                 // class java/lang/Number
     372: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     375: istore        16
     377: iconst_0
     378: istore        17
     380: aload_3
     381: iload         16
     383: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     388: checkcast     #18                 // class java/lang/Number
     391: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     394: iload         5
     396: if_icmpne     403
     399: iconst_1
     400: goto          404
     403: iconst_0
     404: ifeq          348
     407: aload         12
     409: aload         15
     411: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     416: pop
     417: goto          348
     420: aload         12
     422: checkcast     #12                 // class java/util/List
     425: nop
     426: astore        8
     428: aload         7
     430: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.firstOrNull:(Ljava/util/List;)Ljava/lang/Object;
     433: checkcast     #75                 // class java/lang/Integer
     436: dup
     437: ifnull        446
     440: invokevirtual #76                 // Method java/lang/Integer.intValue:()I
     443: goto          448
     446: pop
     447: iload_1
     448: istore        9
     450: aload         7
     452: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;
     455: checkcast     #75                 // class java/lang/Integer
     458: dup
     459: ifnull        468
     462: invokevirtual #76                 // Method java/lang/Integer.intValue:()I
     465: goto          470
     468: pop
     469: iconst_m1
     470: istore        10
     472: new           #81                 // class kotlin/ranges/IntRange
     475: dup
     476: iconst_0
     477: aload         8
     479: invokeinterface #84,  1           // InterfaceMethod java/util/List.size:()I
     484: iload         6
     486: isub
     487: invokespecial #87                 // Method kotlin/ranges/IntRange."<init>":(II)V
     490: checkcast     #24                 // class java/lang/Iterable
     493: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     498: astore        13
     500: aload         13
     502: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     507: ifne          518
     510: new           #89                 // class java/util/NoSuchElementException
     513: dup
     514: invokespecial #90                 // Method java/util/NoSuchElementException."<init>":()V
     517: athrow
     518: aload         13
     520: checkcast     #92                 // class kotlin/collections/IntIterator
     523: invokevirtual #95                 // Method kotlin/collections/IntIterator.nextInt:()I
     526: istore        14
     528: iconst_0
     529: istore        15
     531: aload         8
     533: iload         14
     535: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     540: checkcast     #18                 // class java/lang/Number
     543: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     546: istore        16
     548: aload         8
     550: iload         14
     552: iload         6
     554: iadd
     555: iconst_1
     556: isub
     557: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     562: checkcast     #18                 // class java/lang/Number
     565: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     568: istore        17
     570: iload         17
     572: iload         10
     574: invokestatic  #101                // Method java/lang/Math.max:(II)I
     577: iload         16
     579: iload         9
     581: invokestatic  #104                // Method java/lang/Math.min:(II)I
     584: isub
     585: iconst_1
     586: iadd
     587: istore        14
     589: aload         13
     591: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     596: ifeq          684
     599: aload         13
     601: checkcast     #92                 // class kotlin/collections/IntIterator
     604: invokevirtual #95                 // Method kotlin/collections/IntIterator.nextInt:()I
     607: istore        15
     609: iconst_0
     610: istore        16
     612: aload         8
     614: iload         15
     616: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     621: checkcast     #18                 // class java/lang/Number
     624: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     627: istore        17
     629: aload         8
     631: iload         15
     633: iload         6
     635: iadd
     636: iconst_1
     637: isub
     638: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     643: checkcast     #18                 // class java/lang/Number
     646: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     649: istore        18
     651: iload         18
     653: iload         10
     655: invokestatic  #101                // Method java/lang/Math.max:(II)I
     658: iload         17
     660: iload         9
     662: invokestatic  #104                // Method java/lang/Math.min:(II)I
     665: isub
     666: iconst_1
     667: iadd
     668: istore        15
     670: iload         14
     672: iload         15
     674: if_icmple     589
     677: iload         15
     679: istore        14
     681: goto          589
     684: iload         14
     686: istore        11
     688: getstatic     #110                // Field java/lang/System.out:Ljava/io/PrintStream;
     691: iload         11
     693: invokevirtual #116                // Method java/io/PrintStream.println:(I)V
     696: return

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

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

  public static final void main();
    Code:
       0: iconst_1
       1: istore_0
       2: iconst_0
       3: istore_1
       4: iload_1
       5: iload_0
       6: if_icmpge     22
       9: iload_1
      10: istore_2
      11: iconst_0
      12: istore_3
      13: invokestatic  #197                // Method solve:()V
      16: iinc          1, 1
      19: goto          4
      22: return

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


package yandex.y2023.qual

private fun solve() {
	val (n, m) = readInts()
	val nei = List(2) { List(n + 1) { mutableListOf<Pair<Int, Int>>() } }
	repeat(m) {
		val tokens = readStrings()
		val a = tokens[0].toInt() - 1
		val b = tokens[1].toInt()
		val greater = (tokens[2][0] == '>').toInt()
		val value = tokens[3].toInt()
		nei[greater][b].add(a to value)
	}
	val news = MutableList(2) { IntArray(0) }
	for (c in 1..n) {
		for (greater in 0..1) {
			val neutral = if (greater == 1) Int.MIN_VALUE else Int.MAX_VALUE
			val op: Function2<Int, Int, Int> = if (greater == 1) ::maxOf else ::minOf
			val new = IntArray(n) { neutral }
			news[greater] = new
			for ((b, value) in nei[greater][c]) {
				new[b] = op(new[b], value)
				for ((a, value2) in nei[greater][b]) {
					new[a] = op(new[a], new[b] + value2)
				}
			}
			nei[greater][c].clear()
			for (b in 0 until c) if (new[b] != neutral) nei[greater][c].add(b to new[b])
		}
		for (b in 0 until c) if (news[0][b] < news[1][b]) {
			return println("NO")
		}
	}
	println("YES")
}

private fun readStrings() = readln().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun Boolean.toInt() = if (this) 1 else 0

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

Compiled from "d_wrong.kt"
public final class yandex.y2023.qual.D_wrongKt {
  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: iconst_2
      33: istore        4
      35: new           #24                 // class java/util/ArrayList
      38: dup
      39: iload         4
      41: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      44: astore        5
      46: iconst_0
      47: istore        6
      49: iload         6
      51: iload         4
      53: if_icmpge     155
      56: iload         6
      58: istore        7
      60: aload         5
      62: iload         7
      64: istore        8
      66: astore        18
      68: iconst_0
      69: istore        9
      71: iload_1
      72: iconst_1
      73: iadd
      74: istore        10
      76: new           #24                 // class java/util/ArrayList
      79: dup
      80: iload         10
      82: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      85: astore        11
      87: iconst_0
      88: istore        12
      90: iload         12
      92: iload         10
      94: if_icmpge     136
      97: iload         12
      99: istore        13
     101: aload         11
     103: iload         13
     105: istore        14
     107: astore        15
     109: iconst_0
     110: istore        16
     112: new           #24                 // class java/util/ArrayList
     115: dup
     116: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     119: checkcast     #12                 // class java/util/List
     122: nop
     123: aload         15
     125: swap
     126: invokevirtual #34                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     129: pop
     130: iinc          12, 1
     133: goto          90
     136: aload         11
     138: checkcast     #12                 // class java/util/List
     141: nop
     142: aload         18
     144: swap
     145: invokevirtual #34                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     148: pop
     149: iinc          6, 1
     152: goto          49
     155: aload         5
     157: checkcast     #12                 // class java/util/List
     160: astore_3
     161: iconst_0
     162: istore        4
     164: iload         4
     166: iload_2
     167: if_icmpge     309
     170: iload         4
     172: istore        5
     174: iconst_0
     175: istore        6
     177: invokestatic  #37                 // Method readStrings:()Ljava/util/List;
     180: astore        7
     182: aload         7
     184: iconst_0
     185: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     190: checkcast     #39                 // class java/lang/String
     193: invokestatic  #45                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     196: iconst_1
     197: isub
     198: istore        8
     200: aload         7
     202: iconst_1
     203: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     208: checkcast     #39                 // class java/lang/String
     211: invokestatic  #45                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     214: istore        9
     216: aload         7
     218: iconst_2
     219: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     224: checkcast     #39                 // class java/lang/String
     227: iconst_0
     228: invokevirtual #49                 // Method java/lang/String.charAt:(I)C
     231: bipush        62
     233: if_icmpne     240
     236: iconst_1
     237: goto          241
     240: iconst_0
     241: invokestatic  #53                 // Method toInt:(Z)I
     244: istore        10
     246: aload         7
     248: iconst_3
     249: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #39                 // class java/lang/String
     257: invokestatic  #45                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     260: istore        11
     262: aload_3
     263: iload         10
     265: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     270: checkcast     #12                 // class java/util/List
     273: iload         9
     275: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     280: checkcast     #12                 // class java/util/List
     283: iload         8
     285: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     288: iload         11
     290: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     293: invokestatic  #63                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     296: invokeinterface #64,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     301: pop
     302: nop
     303: iinc          4, 1
     306: goto          164
     309: iconst_2
     310: istore        5
     312: new           #24                 // class java/util/ArrayList
     315: dup
     316: iload         5
     318: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     321: astore        6
     323: iconst_0
     324: istore        7
     326: iload         7
     328: iload         5
     330: if_icmpge     364
     333: iload         7
     335: istore        8
     337: aload         6
     339: iload         8
     341: istore        9
     343: astore        18
     345: iconst_0
     346: istore        10
     348: iconst_0
     349: newarray       int
     351: aload         18
     353: swap
     354: invokevirtual #34                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     357: pop
     358: iinc          7, 1
     361: goto          326
     364: aload         6
     366: checkcast     #12                 // class java/util/List
     369: astore        4
     371: iconst_1
     372: istore        5
     374: iload         5
     376: iload_1
     377: if_icmpgt     867
     380: iconst_0
     381: istore        6
     383: iload         6
     385: iconst_2
     386: if_icmpge     798
     389: iload         6
     391: iconst_1
     392: if_icmpne     400
     395: ldc           #65                 // int -2147483648
     397: goto          402
     400: ldc           #66                 // int 2147483647
     402: istore        7
     404: iload         6
     406: iconst_1
     407: if_icmpne     419
     410: getstatic     #72                 // Field yandex/y2023/qual/D_wrongKt$solve$op$1.INSTANCE:Lyandex/y2023/qual/D_wrongKt$solve$op$1;
     413: checkcast     #74                 // class kotlin/jvm/functions/Function2
     416: goto          425
     419: getstatic     #79                 // Field yandex/y2023/qual/D_wrongKt$solve$op$2.INSTANCE:Lyandex/y2023/qual/D_wrongKt$solve$op$2;
     422: checkcast     #74                 // class kotlin/jvm/functions/Function2
     425: astore        8
     427: iconst_0
     428: istore        10
     430: iload_1
     431: newarray       int
     433: astore        11
     435: iload         10
     437: iload_1
     438: if_icmpge     458
     441: iload         10
     443: istore        12
     445: aload         11
     447: iload         12
     449: iload         7
     451: iastore
     452: iinc          10, 1
     455: goto          435
     458: aload         11
     460: astore        9
     462: aload         4
     464: iload         6
     466: aload         9
     468: invokeinterface #83,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     473: pop
     474: aload_3
     475: iload         6
     477: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     482: checkcast     #12                 // class java/util/List
     485: iload         5
     487: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     492: checkcast     #12                 // class java/util/List
     495: invokeinterface #87,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     500: astore        10
     502: aload         10
     504: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     509: ifeq          697
     512: aload         10
     514: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     519: checkcast     #99                 // class kotlin/Pair
     522: astore        11
     524: aload         11
     526: invokevirtual #102                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     529: checkcast     #18                 // class java/lang/Number
     532: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     535: istore        12
     537: aload         11
     539: invokevirtual #105                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     542: checkcast     #18                 // class java/lang/Number
     545: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     548: istore        13
     550: aload         9
     552: iload         12
     554: aload         8
     556: aload         9
     558: iload         12
     560: iaload
     561: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     564: iload         13
     566: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     569: invokeinterface #109,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     574: checkcast     #18                 // class java/lang/Number
     577: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     580: iastore
     581: aload_3
     582: iload         6
     584: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     589: checkcast     #12                 // class java/util/List
     592: iload         12
     594: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     599: checkcast     #12                 // class java/util/List
     602: invokeinterface #87,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     607: astore        14
     609: aload         14
     611: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     616: ifeq          502
     619: aload         14
     621: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     626: checkcast     #99                 // class kotlin/Pair
     629: astore        15
     631: aload         15
     633: invokevirtual #102                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     636: checkcast     #18                 // class java/lang/Number
     639: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     642: istore        16
     644: aload         15
     646: invokevirtual #105                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     649: checkcast     #18                 // class java/lang/Number
     652: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     655: istore        17
     657: aload         9
     659: iload         16
     661: aload         8
     663: aload         9
     665: iload         16
     667: iaload
     668: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     671: aload         9
     673: iload         12
     675: iaload
     676: iload         17
     678: iadd
     679: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     682: invokeinterface #109,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     687: checkcast     #18                 // class java/lang/Number
     690: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     693: iastore
     694: goto          609
     697: aload_3
     698: iload         6
     700: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     705: checkcast     #12                 // class java/util/List
     708: iload         5
     710: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     715: checkcast     #12                 // class java/util/List
     718: invokeinterface #112,  1          // InterfaceMethod java/util/List.clear:()V
     723: iconst_0
     724: istore        10
     726: iload         10
     728: iload         5
     730: if_icmpge     792
     733: aload         9
     735: iload         10
     737: iaload
     738: iload         7
     740: if_icmpeq     786
     743: aload_3
     744: iload         6
     746: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     751: checkcast     #12                 // class java/util/List
     754: iload         5
     756: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     761: checkcast     #12                 // class java/util/List
     764: iload         10
     766: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     769: aload         9
     771: iload         10
     773: iaload
     774: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     777: invokestatic  #63                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     780: invokeinterface #64,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     785: pop
     786: iinc          10, 1
     789: goto          726
     792: iinc          6, 1
     795: goto          383
     798: iconst_0
     799: istore        6
     801: iload         6
     803: iload         5
     805: if_icmpge     855
     808: aload         4
     810: iconst_0
     811: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     816: checkcast     #114                // class "[I"
     819: iload         6
     821: iaload
     822: aload         4
     824: iconst_1
     825: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     830: checkcast     #114                // class "[I"
     833: iload         6
     835: iaload
     836: if_icmpge     849
     839: ldc           #116                // String NO
     841: getstatic     #122                // Field java/lang/System.out:Ljava/io/PrintStream;
     844: swap
     845: invokevirtual #128                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     848: return
     849: iinc          6, 1
     852: goto          801
     855: iload         5
     857: iload_1
     858: if_icmpeq     867
     861: iinc          5, 1
     864: goto          380
     867: ldc           #130                // String YES
     869: getstatic     #122                // Field java/lang/System.out:Ljava/io/PrintStream;
     872: swap
     873: invokevirtual #128                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     876: return

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

  private static final int toInt(boolean);
    Code:
       0: iload_0
       1: ifeq          8
       4: iconst_1
       5: goto          9
       8: iconst_0
       9: ireturn

  public static final void main();
    Code:
       0: iconst_1
       1: istore_0
       2: iconst_0
       3: istore_1
       4: iload_1
       5: iload_0
       6: if_icmpge     22
       9: iload_1
      10: istore_2
      11: iconst_0
      12: istore_3
      13: invokestatic  #198                // Method solve:()V
      16: iinc          1, 1
      19: goto          4
      22: return

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

Compiled from "d_wrong.kt"
final class yandex.y2023.qual.D_wrongKt$solve$op$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Integer, java.lang.Integer, java.lang.Integer> {
  public static final yandex.y2023.qual.D_wrongKt$solve$op$2 INSTANCE;

  yandex.y2023.qual.D_wrongKt$solve$op$2();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class kotlin/comparisons/ComparisonsKt
       4: ldc           #13                 // String minOf
       6: ldc           #15                 // String minOf(II)I
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Integer invoke(int, int);
    Code:
       0: iload_1
       1: iload_2
       2: invokestatic  #28                 // Method java/lang/Math.min:(II)I
       5: invokestatic  #34                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/Number
       5: invokevirtual #44                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #40                 // class java/lang/Number
      12: invokevirtual #44                 // Method java/lang/Number.intValue:()I
      15: invokevirtual #46                 // Method invoke:(II)Ljava/lang/Integer;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class yandex/y2023/qual/D_wrongKt$solve$op$2
       3: dup
       4: invokespecial #51                 // Method "<init>":()V
       7: putstatic     #54                 // Field INSTANCE:Lyandex/y2023/qual/D_wrongKt$solve$op$2;
      10: return
}

Compiled from "d_wrong.kt"
final class yandex.y2023.qual.D_wrongKt$solve$op$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Integer, java.lang.Integer, java.lang.Integer> {
  public static final yandex.y2023.qual.D_wrongKt$solve$op$1 INSTANCE;

  yandex.y2023.qual.D_wrongKt$solve$op$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class kotlin/comparisons/ComparisonsKt
       4: ldc           #13                 // String maxOf
       6: ldc           #15                 // String maxOf(II)I
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Integer invoke(int, int);
    Code:
       0: iload_1
       1: iload_2
       2: invokestatic  #28                 // Method java/lang/Math.max:(II)I
       5: invokestatic  #34                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/Number
       5: invokevirtual #44                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #40                 // class java/lang/Number
      12: invokevirtual #44                 // Method java/lang/Number.intValue:()I
      15: invokevirtual #46                 // Method invoke:(II)Ljava/lang/Integer;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class yandex/y2023/qual/D_wrongKt$solve$op$1
       3: dup
       4: invokespecial #51                 // Method "<init>":()V
       7: putstatic     #54                 // Field INSTANCE:Lyandex/y2023/qual/D_wrongKt$solve$op$1;
      10: return
}


package yandex.y2023.qual

private fun solve(): String {
	val (n, m) = readInts()
	data class Edge(val from: Int, val to: Int, val weight: Int)
	val edges = List(m) {
		val tokens = readStrings()
		val a = tokens[0].toInt() - 1
		val b = tokens[1].toInt()
		val greater = (tokens[2][0] == '>')
		val value = tokens[3].toInt()
		if (greater) Edge(a, b, -value) else Edge(b, a, value)
	}
	val p = LongArray(n + 1)
	for (iter in 0..n) {
		for (edge in edges) {
			if (p[edge.to] > p[edge.from] + edge.weight) {
				if (iter == n) return "NO"
				p[edge.to] = p[edge.from] + edge.weight
			}
		}
	}
	return "YES"
}

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

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

Compiled from "d.kt"
public final class yandex.y2023.qual.DKt {
  private static final java.lang.String 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_2
      37: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      40: astore        4
      42: iconst_0
      43: istore        5
      45: iload         5
      47: iload_2
      48: if_icmpge     196
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        14
      63: iconst_0
      64: istore        8
      66: invokestatic  #31                 // Method readStrings:()Ljava/util/List;
      69: astore        9
      71: aload         9
      73: iconst_0
      74: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: checkcast     #33                 // class java/lang/String
      82: invokestatic  #39                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      85: iconst_1
      86: isub
      87: istore        10
      89: aload         9
      91: iconst_1
      92: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #33                 // class java/lang/String
     100: invokestatic  #39                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     103: istore        11
     105: aload         9
     107: iconst_2
     108: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     113: checkcast     #33                 // class java/lang/String
     116: iconst_0
     117: invokevirtual #43                 // Method java/lang/String.charAt:(I)C
     120: bipush        62
     122: if_icmpne     129
     125: iconst_1
     126: goto          130
     129: iconst_0
     130: istore        12
     132: aload         9
     134: iconst_3
     135: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     140: checkcast     #33                 // class java/lang/String
     143: invokestatic  #39                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     146: istore        13
     148: iload         12
     150: ifeq          170
     153: new           #45                 // class yandex/y2023/qual/DKt$solve$Edge
     156: dup
     157: iload         10
     159: iload         11
     161: iload         13
     163: ineg
     164: invokespecial #48                 // Method yandex/y2023/qual/DKt$solve$Edge."<init>":(III)V
     167: goto          183
     170: new           #45                 // class yandex/y2023/qual/DKt$solve$Edge
     173: dup
     174: iload         11
     176: iload         10
     178: iload         13
     180: invokespecial #48                 // Method yandex/y2023/qual/DKt$solve$Edge."<init>":(III)V
     183: aload         14
     185: swap
     186: invokevirtual #52                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     189: pop
     190: iinc          5, 1
     193: goto          45
     196: aload         4
     198: checkcast     #12                 // class java/util/List
     201: astore_3
     202: iload_1
     203: iconst_1
     204: iadd
     205: newarray       long
     207: astore        4
     209: iconst_0
     210: istore        5
     212: iload         5
     214: iload_1
     215: if_icmpgt     322
     218: aload_3
     219: invokeinterface #56,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     224: astore        6
     226: aload         6
     228: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     233: ifeq          310
     236: aload         6
     238: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     243: checkcast     #45                 // class yandex/y2023/qual/DKt$solve$Edge
     246: astore        7
     248: aload         4
     250: aload         7
     252: invokevirtual #69                 // Method yandex/y2023/qual/DKt$solve$Edge.getTo:()I
     255: laload
     256: aload         4
     258: aload         7
     260: invokevirtual #72                 // Method yandex/y2023/qual/DKt$solve$Edge.getFrom:()I
     263: laload
     264: aload         7
     266: invokevirtual #75                 // Method yandex/y2023/qual/DKt$solve$Edge.getWeight:()I
     269: i2l
     270: ladd
     271: lcmp
     272: ifle          226
     275: iload         5
     277: iload_1
     278: if_icmpne     284
     281: ldc           #77                 // String NO
     283: areturn
     284: aload         4
     286: aload         7
     288: invokevirtual #69                 // Method yandex/y2023/qual/DKt$solve$Edge.getTo:()I
     291: aload         4
     293: aload         7
     295: invokevirtual #72                 // Method yandex/y2023/qual/DKt$solve$Edge.getFrom:()I
     298: laload
     299: aload         7
     301: invokevirtual #75                 // Method yandex/y2023/qual/DKt$solve$Edge.getWeight:()I
     304: i2l
     305: ladd
     306: lastore
     307: goto          226
     310: iload         5
     312: iload_1
     313: if_icmpeq     322
     316: iinc          5, 1
     319: goto          218
     322: ldc           #79                 // String YES
     324: areturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #104                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: checkcast     #106                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #33                 // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #108                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #114                // 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  #31                 // Method readStrings:()Ljava/util/List;
       3: checkcast     #117                // 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  #123                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #125                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          92
      49: aload         5
      51: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #33                 // class java/lang/String
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokestatic  #39                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      76: nop
      77: invokestatic  #130                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: aload         9
      82: swap
      83: invokeinterface #131,  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 final void main();
    Code:
       0: iconst_1
       1: istore_0
       2: iconst_0
       3: istore_1
       4: iload_1
       5: iload_0
       6: if_icmpge     30
       9: iload_1
      10: istore_2
      11: iconst_0
      12: istore_3
      13: invokestatic  #146                // Method solve:()Ljava/lang/String;
      16: getstatic     #152                // Field java/lang/System.out:Ljava/io/PrintStream;
      19: swap
      20: invokevirtual #158                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      23: nop
      24: iinc          1, 1
      27: goto          4
      30: return

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

Compiled from "d.kt"
public final class yandex.y2023.qual.DKt$solve$Edge {
  private final int from;

  private final int to;

  private final int weight;

  public yandex.y2023.qual.DKt$solve$Edge(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 from:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field to:I
      14: aload_0
      15: iload_3
      16: putfield      #19                 // Field weight:I
      19: return

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

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

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

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

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

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

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

  public static yandex.y2023.qual.DKt$solve$Edge copy$default(yandex.y2023.qual.DKt$solve$Edge, 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 from:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field to:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #19                 // Field weight:I
      35: istore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: iload_3
      40: invokevirtual #36                 // Method copy:(III)Lyandex/y2023/qual/DKt$solve$Edge;
      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 Edge(from=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field from:I
      16: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #52                 // String , to=
      21: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field to:I
      28: invokevirtual #50                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #54                 // String , weight=
      33: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #19                 // Field weight: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 from: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 to: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 weight: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 yandex/y2023/qual/DKt$solve$Edge
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class yandex/y2023/qual/DKt$solve$Edge
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field from:I
      25: aload_2
      26: getfield      #13                 // Field from:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field to:I
      38: aload_2
      39: getfield      #16                 // Field to:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #19                 // Field weight:I
      51: aload_2
      52: getfield      #19                 // Field weight:I
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: iconst_1
      61: ireturn
}


package yandex.y2021.qual

fun main() {
	val (hei, wid) = readInts()
	val f = List(hei) { readLn().map { it - '0' } }
	val countZero = f.sumOf { row -> row.count { it == 0 } }
	val inf = hei * wid * 3
	val a = List(wid + 1) { List(hei + 1) { IntArray(wid * hei + 1) { inf } } }
	for (y in 0..hei) a[0][y][0] = 0
	for (x in 0 until wid) {
		val ones = IntArray(hei + 1)
		for (y in 0 until hei) {
			ones[y + 1] = ones[y] + f[y][x]
		}
		val prev = a[x]
		val next = a[x + 1]
		for (y in 0..hei) {
			val prevY = prev[y]
			val nextY = next[y]
			val onesY = ones[y]
			for (z in x * y..wid * hei - y) {
				nextY[z + y] = minOf(nextY[z + y], prevY[z] + onesY)
			}
		}
		for (y in hei - 1 downTo 0) {
			val nextY = next[y]
			val nextY1 = next[y + 1]
			for (z in 0..wid * hei) {
				nextY[z] = minOf(nextY[z], nextY1[z])
			}
		}
	}
	println(a[wid][0][countZero])
}

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

Compiled from "e.kt"
public final class yandex.y2021.qual.EKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method readInts:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: iconst_0
       6: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      11: checkcast     #18                 // class java/lang/Number
      14: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      17: istore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #18                 // class java/lang/Number
      28: invokevirtual #22                 // Method java/lang/Number.intValue:()I
      31: istore_2
      32: 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     183
      51: iload         5
      53: istore        6
      55: aload         4
      57: iload         6
      59: istore        7
      61: astore        24
      63: iconst_0
      64: istore        8
      66: invokestatic  #32                 // Method readLn:()Ljava/lang/String;
      69: checkcast     #34                 // class java/lang/CharSequence
      72: astore        9
      74: iconst_0
      75: istore        10
      77: aload         9
      79: astore        11
      81: new           #24                 // class java/util/ArrayList
      84: dup
      85: aload         9
      87: invokeinterface #37,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      92: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      95: checkcast     #39                 // class java/util/Collection
      98: astore        12
     100: iconst_0
     101: istore        13
     103: iconst_0
     104: istore        14
     106: iload         14
     108: aload         11
     110: invokeinterface #37,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     115: if_icmpge     163
     118: aload         11
     120: iload         14
     122: invokeinterface #43,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     127: istore        15
     129: aload         12
     131: iload         15
     133: istore        16
     135: astore        17
     137: iconst_0
     138: istore        18
     140: iload         16
     142: bipush        48
     144: isub
     145: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     148: aload         17
     150: swap
     151: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     156: pop
     157: iinc          14, 1
     160: goto          106
     163: aload         12
     165: checkcast     #12                 // class java/util/List
     168: nop
     169: nop
     170: aload         24
     172: swap
     173: invokevirtual #54                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     176: pop
     177: iinc          5, 1
     180: goto          45
     183: aload         4
     185: checkcast     #12                 // class java/util/List
     188: astore_3
     189: aload_3
     190: checkcast     #56                 // class java/lang/Iterable
     193: astore        5
     195: iconst_0
     196: istore        6
     198: aload         5
     200: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     205: astore        7
     207: aload         7
     209: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     214: ifeq          361
     217: aload         7
     219: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     224: astore        8
     226: iload         6
     228: aload         8
     230: checkcast     #12                 // class java/util/List
     233: astore        9
     235: istore        24
     237: iconst_0
     238: istore        10
     240: aload         9
     242: checkcast     #56                 // class java/lang/Iterable
     245: astore        11
     247: iconst_0
     248: istore        12
     250: aload         11
     252: instanceof    #39                 // class java/util/Collection
     255: ifeq          275
     258: aload         11
     260: checkcast     #39                 // class java/util/Collection
     263: invokeinterface #73,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     268: ifeq          275
     271: iconst_0
     272: goto          348
     275: iconst_0
     276: istore        13
     278: aload         11
     280: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     285: astore        14
     287: aload         14
     289: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifeq          346
     297: aload         14
     299: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     304: astore        15
     306: aload         15
     308: checkcast     #18                 // class java/lang/Number
     311: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     314: istore        16
     316: iconst_0
     317: istore        17
     319: iload         16
     321: ifne          328
     324: iconst_1
     325: goto          329
     328: iconst_0
     329: ifeq          287
     332: iinc          13, 1
     335: iload         13
     337: ifge          287
     340: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     343: goto          287
     346: iload         13
     348: nop
     349: istore        25
     351: iload         24
     353: iload         25
     355: iadd
     356: istore        6
     358: goto          207
     361: iload         6
     363: istore        4
     365: iload_1
     366: iload_2
     367: imul
     368: iconst_3
     369: imul
     370: istore        5
     372: iload_2
     373: iconst_1
     374: iadd
     375: istore        7
     377: new           #24                 // class java/util/ArrayList
     380: dup
     381: iload         7
     383: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     386: astore        8
     388: iconst_0
     389: istore        9
     391: iload         9
     393: iload         7
     395: if_icmpge     528
     398: iload         9
     400: istore        10
     402: aload         8
     404: iload         10
     406: istore        11
     408: astore        24
     410: iconst_0
     411: istore        12
     413: iload_1
     414: iconst_1
     415: iadd
     416: istore        13
     418: new           #24                 // class java/util/ArrayList
     421: dup
     422: iload         13
     424: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     427: astore        14
     429: iconst_0
     430: istore        15
     432: iload         15
     434: iload         13
     436: if_icmpge     509
     439: iload         15
     441: istore        16
     443: aload         14
     445: iload         16
     447: istore        17
     449: astore        18
     451: iconst_0
     452: istore        19
     454: iconst_0
     455: istore        20
     457: iload_2
     458: iload_1
     459: imul
     460: iconst_1
     461: iadd
     462: istore        21
     464: iload         21
     466: newarray       int
     468: astore        22
     470: iload         20
     472: iload         21
     474: if_icmpge     494
     477: iload         20
     479: istore        23
     481: aload         22
     483: iload         23
     485: iload         5
     487: iastore
     488: iinc          20, 1
     491: goto          470
     494: aload         22
     496: aload         18
     498: swap
     499: invokevirtual #54                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     502: pop
     503: iinc          15, 1
     506: goto          432
     509: aload         14
     511: checkcast     #12                 // class java/util/List
     514: nop
     515: aload         24
     517: swap
     518: invokevirtual #54                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     521: pop
     522: iinc          9, 1
     525: goto          391
     528: aload         8
     530: checkcast     #12                 // class java/util/List
     533: astore        6
     535: iconst_0
     536: istore        7
     538: iload         7
     540: iload_1
     541: if_icmpgt     580
     544: aload         6
     546: iconst_0
     547: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     552: checkcast     #12                 // class java/util/List
     555: iload         7
     557: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     562: checkcast     #80                 // class "[I"
     565: iconst_0
     566: iconst_0
     567: iastore
     568: iload         7
     570: iload_1
     571: if_icmpeq     580
     574: iinc          7, 1
     577: goto          544
     580: iconst_0
     581: istore        7
     583: iload         7
     585: iload_2
     586: if_icmpge     895
     589: iload_1
     590: iconst_1
     591: iadd
     592: newarray       int
     594: astore        8
     596: iconst_0
     597: istore        9
     599: iload         9
     601: iload_1
     602: if_icmpge     648
     605: aload         8
     607: iload         9
     609: iconst_1
     610: iadd
     611: aload         8
     613: iload         9
     615: iaload
     616: aload_3
     617: iload         9
     619: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     624: checkcast     #12                 // class java/util/List
     627: iload         7
     629: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     634: checkcast     #18                 // class java/lang/Number
     637: invokevirtual #22                 // Method java/lang/Number.intValue:()I
     640: iadd
     641: iastore
     642: iinc          9, 1
     645: goto          599
     648: aload         6
     650: iload         7
     652: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     657: checkcast     #12                 // class java/util/List
     660: astore        9
     662: aload         6
     664: iload         7
     666: iconst_1
     667: iadd
     668: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     673: checkcast     #12                 // class java/util/List
     676: astore        10
     678: iconst_0
     679: istore        11
     681: iload         11
     683: iload_1
     684: if_icmpgt     796
     687: aload         9
     689: iload         11
     691: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     696: checkcast     #80                 // class "[I"
     699: astore        12
     701: aload         10
     703: iload         11
     705: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     710: checkcast     #80                 // class "[I"
     713: astore        13
     715: aload         8
     717: iload         11
     719: iaload
     720: istore        14
     722: iload         7
     724: iload         11
     726: imul
     727: istore        15
     729: iload_2
     730: iload_1
     731: imul
     732: iload         11
     734: isub
     735: istore        16
     737: iload         15
     739: iload         16
     741: if_icmpgt     784
     744: aload         13
     746: iload         15
     748: iload         11
     750: iadd
     751: aload         13
     753: iload         15
     755: iload         11
     757: iadd
     758: iaload
     759: aload         12
     761: iload         15
     763: iaload
     764: iload         14
     766: iadd
     767: invokestatic  #86                 // Method java/lang/Math.min:(II)I
     770: iastore
     771: iload         15
     773: iload         16
     775: if_icmpeq     784
     778: iinc          15, 1
     781: goto          744
     784: iload         11
     786: iload_1
     787: if_icmpeq     796
     790: iinc          11, 1
     793: goto          687
     796: iload_1
     797: iconst_1
     798: isub
     799: istore        11
     801: iconst_m1
     802: iload         11
     804: if_icmpge     889
     807: aload         10
     809: iload         11
     811: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     816: checkcast     #80                 // class "[I"
     819: astore        12
     821: aload         10
     823: iload         11
     825: iconst_1
     826: iadd
     827: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     832: checkcast     #80                 // class "[I"
     835: astore        13
     837: iconst_0
     838: istore        14
     840: iload_2
     841: iload_1
     842: imul
     843: istore        15
     845: iload         14
     847: iload         15
     849: if_icmpgt     883
     852: aload         12
     854: iload         14
     856: aload         12
     858: iload         14
     860: iaload
     861: aload         13
     863: iload         14
     865: iaload
     866: invokestatic  #86                 // Method java/lang/Math.min:(II)I
     869: iastore
     870: iload         14
     872: iload         15
     874: if_icmpeq     883
     877: iinc          14, 1
     880: goto          852
     883: iinc          11, -1
     886: goto          801
     889: iinc          7, 1
     892: goto          583
     895: aload         6
     897: iload_2
     898: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     903: checkcast     #12                 // class java/util/List
     906: iconst_0
     907: invokeinterface #16,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     912: checkcast     #80                 // class "[I"
     915: iload         4
     917: iaload
     918: istore        7
     920: getstatic     #92                 // Field java/lang/System.out:Ljava/io/PrintStream;
     923: iload         7
     925: invokevirtual #97                 // Method java/io/PrintStream.println:(I)V
     928: return

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

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


package yandex.y2020.qual

private fun solve(): Boolean {
	readLn()
	val a = readInts().sorted()
	readLn()
	val b = readInts().sorted()
	if (a.size != b.size) return false
	if (a.isEmpty()) return true
	val aSame = a.all { it == a[0] }
	val bSame = b.all { it == b[0] }
	if (aSame && bSame) return true
	if (aSame || bSame) return false
	return good(a, b) || good(a, b.reversed())
}

private fun good(a: List<Int>, b: List<Int>): Boolean {
	return a.indices.all {
		(a[it] - a.first()).toLong() * (b.last() - b.first()) ==
				(b[it] - b.first()).toLong() * (a.last() - a.first())
	}
}

fun main() = repeat(readInt()) { println(if (solve()) "YES" else "NO") }

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

Compiled from "c.kt"
public final class yandex.y2020.qual.CKt {
  private static final boolean solve();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: pop
       4: invokestatic  #14                 // Method readInts:()Ljava/util/List;
       7: checkcast     #16                 // class java/lang/Iterable
      10: invokestatic  #22                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      13: astore_0
      14: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
      17: pop
      18: invokestatic  #14                 // Method readInts:()Ljava/util/List;
      21: checkcast     #16                 // class java/lang/Iterable
      24: invokestatic  #22                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      27: astore_1
      28: aload_0
      29: invokeinterface #28,  1           // InterfaceMethod java/util/List.size:()I
      34: aload_1
      35: invokeinterface #28,  1           // InterfaceMethod java/util/List.size:()I
      40: if_icmpeq     45
      43: iconst_0
      44: ireturn
      45: aload_0
      46: invokeinterface #31,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      51: ifeq          56
      54: iconst_1
      55: ireturn
      56: aload_0
      57: checkcast     #16                 // class java/lang/Iterable
      60: astore_3
      61: iconst_0
      62: istore        4
      64: aload_3
      65: instanceof    #33                 // class java/util/Collection
      68: ifeq          87
      71: aload_3
      72: checkcast     #33                 // class java/util/Collection
      75: invokeinterface #34,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      80: ifeq          87
      83: iconst_1
      84: goto          158
      87: aload_3
      88: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      93: astore        5
      95: aload         5
      97: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     102: ifeq          157
     105: aload         5
     107: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     112: astore        6
     114: aload         6
     116: checkcast     #49                 // class java/lang/Number
     119: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     122: istore        7
     124: iconst_0
     125: istore        8
     127: iload         7
     129: aload_0
     130: iconst_0
     131: invokeinterface #56,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     136: checkcast     #49                 // class java/lang/Number
     139: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     142: if_icmpne     149
     145: iconst_1
     146: goto          150
     149: iconst_0
     150: ifne          95
     153: iconst_0
     154: goto          158
     157: iconst_1
     158: istore_2
     159: aload_1
     160: checkcast     #16                 // class java/lang/Iterable
     163: astore        4
     165: iconst_0
     166: istore        5
     168: aload         4
     170: instanceof    #33                 // class java/util/Collection
     173: ifeq          193
     176: aload         4
     178: checkcast     #33                 // class java/util/Collection
     181: invokeinterface #34,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     186: ifeq          193
     189: iconst_1
     190: goto          265
     193: aload         4
     195: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     200: astore        6
     202: aload         6
     204: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     209: ifeq          264
     212: aload         6
     214: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     219: astore        7
     221: aload         7
     223: checkcast     #49                 // class java/lang/Number
     226: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     229: istore        8
     231: iconst_0
     232: istore        9
     234: iload         8
     236: aload_1
     237: iconst_0
     238: invokeinterface #56,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     243: checkcast     #49                 // class java/lang/Number
     246: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     249: if_icmpne     256
     252: iconst_1
     253: goto          257
     256: iconst_0
     257: ifne          202
     260: iconst_0
     261: goto          265
     264: iconst_1
     265: istore_3
     266: iload_2
     267: ifeq          276
     270: iload_3
     271: ifeq          276
     274: iconst_1
     275: ireturn
     276: iload_2
     277: ifne          284
     280: iload_3
     281: ifeq          286
     284: iconst_0
     285: ireturn
     286: aload_0
     287: aload_1
     288: invokestatic  #60                 // Method good:(Ljava/util/List;Ljava/util/List;)Z
     291: ifne          308
     294: aload_0
     295: aload_1
     296: checkcast     #16                 // class java/lang/Iterable
     299: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     302: invokestatic  #60                 // Method good:(Ljava/util/List;Ljava/util/List;)Z
     305: ifeq          312
     308: iconst_1
     309: goto          313
     312: iconst_0
     313: ireturn

  private static final boolean good(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #33                 // class java/util/Collection
       4: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
       7: checkcast     #16                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: instanceof    #33                 // class java/util/Collection
      17: ifeq          36
      20: aload_2
      21: checkcast     #33                 // class java/util/Collection
      24: invokeinterface #34,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      29: ifeq          36
      32: iconst_1
      33: goto          187
      36: aload_2
      37: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        4
      44: aload         4
      46: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          186
      54: aload         4
      56: checkcast     #85                 // class kotlin/collections/IntIterator
      59: invokevirtual #88                 // Method kotlin/collections/IntIterator.nextInt:()I
      62: istore        5
      64: iload         5
      66: istore        6
      68: iconst_0
      69: istore        7
      71: aload_0
      72: iload         6
      74: invokeinterface #56,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: checkcast     #49                 // class java/lang/Number
      82: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      85: aload_0
      86: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      89: checkcast     #49                 // class java/lang/Number
      92: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      95: isub
      96: i2l
      97: aload_1
      98: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     101: checkcast     #49                 // class java/lang/Number
     104: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     107: aload_1
     108: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     111: checkcast     #49                 // class java/lang/Number
     114: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     117: isub
     118: i2l
     119: lmul
     120: aload_1
     121: iload         6
     123: invokeinterface #56,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     128: checkcast     #49                 // class java/lang/Number
     131: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     134: aload_1
     135: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     138: checkcast     #49                 // class java/lang/Number
     141: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     144: isub
     145: i2l
     146: aload_0
     147: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     150: checkcast     #49                 // class java/lang/Number
     153: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     156: aload_0
     157: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     160: checkcast     #49                 // class java/lang/Number
     163: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     166: isub
     167: i2l
     168: lmul
     169: lcmp
     170: ifne          177
     173: iconst_1
     174: goto          178
     177: iconst_0
     178: nop
     179: ifne          44
     182: iconst_0
     183: goto          187
     186: iconst_1
     187: ireturn

  public static final void main();
    Code:
       0: invokestatic  #101                // Method readInt:()I
       3: istore_0
       4: iconst_0
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpge     42
      11: iload_1
      12: istore_2
      13: iconst_0
      14: istore_3
      15: invokestatic  #103                // Method solve:()Z
      18: ifeq          26
      21: ldc           #105                // String YES
      23: goto          28
      26: ldc           #107                // String NO
      28: getstatic     #113                // Field java/lang/System.out:Ljava/io/PrintStream;
      31: swap
      32: invokevirtual #119                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      35: nop
      36: iinc          1, 1
      39: goto          6
      42: return

  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #127                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #132                // 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  #138                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       6: ireturn

  private static final java.util.List<java.lang.String> readStrings();
    Code:
       0: invokestatic  #10                 // Method readLn:()Ljava/lang/String;
       3: checkcast     #142                // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #122                // class java/lang/String
      10: astore_0
      11: aload_0
      12: iconst_0
      13: ldc           #144                // String
      15: aastore
      16: aload_0
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #150                // 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  #153                // Method readStrings:()Ljava/util/List;
       3: checkcast     #16                 // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #155                // class java/util/ArrayList
      14: dup
      15: invokespecial #158                // Method java/util/ArrayList."<init>":()V
      18: checkcast     #33                 // class java/util/Collection
      21: astore_3
      22: iconst_0
      23: istore        4
      25: aload_2
      26: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        5
      33: aload         5
      35: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          96
      43: aload         5
      45: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        6
      52: aload         6
      54: checkcast     #122                // class java/lang/String
      57: astore        7
      59: iconst_0
      60: istore        8
      62: aload         7
      64: checkcast     #142                // class java/lang/CharSequence
      67: invokeinterface #161,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      72: ifle          79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: nop
      81: ifeq          33
      84: aload_3
      85: aload         6
      87: invokeinterface #165,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          33
      96: aload_3
      97: checkcast     #24                 // class java/util/List
     100: nop
     101: checkcast     #16                 // class java/lang/Iterable
     104: astore_0
     105: nop
     106: iconst_0
     107: istore_1
     108: aload_0
     109: astore_2
     110: new           #155                // class java/util/ArrayList
     113: dup
     114: aload_0
     115: bipush        10
     117: invokestatic  #169                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     120: invokespecial #172                // Method java/util/ArrayList."<init>":(I)V
     123: checkcast     #33                 // class java/util/Collection
     126: astore_3
     127: iconst_0
     128: istore        4
     130: aload_2
     131: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     136: astore        5
     138: aload         5
     140: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     145: ifeq          191
     148: aload         5
     150: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     155: astore        6
     157: aload_3
     158: aload         6
     160: checkcast     #122                // class java/lang/String
     163: astore        7
     165: astore        9
     167: iconst_0
     168: istore        8
     170: aload         7
     172: invokestatic  #138                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     175: nop
     176: invokestatic  #176                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     179: aload         9
     181: swap
     182: invokeinterface #165,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     187: pop
     188: goto          138
     191: aload_3
     192: checkcast     #24                 // class java/util/List
     195: nop
     196: areturn

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