import java.util.*
import kotlin.math.abs

// 棋盘大小
const val BOARD_SIZE = 15

// 评估函数（简化版本，根据棋局评估得分）
// 五子棋中针对当前局面的评估函数
fun evaluate(board: Array<Array<Int>>, player: Int): Int {
    val opponent = if (player == 2) 1 else 2
    var score = 0

    // 检查每个位置的行、列、对角线是否存在连续的棋子
    for (i in 0 until BOARD_SIZE) {
        for (j in 0 until BOARD_SIZE) {
            // 检查水平、垂直和对角线上的棋子情况
            val directions = arrayOf(
                intArrayOf(1, 0), intArrayOf(1, -1),
                intArrayOf(0, -1), intArrayOf(-1, -1),
                intArrayOf(-1, 0), intArrayOf(-1, 1),
                intArrayOf(0, 1), intArrayOf(1, 1)
            )

            for (dir in directions) {
                var countPlayer = 0
                var countOpponent = 0
                var association = 0
                for (k in 0 until 6) {
                    val r = i + k * dir[0]
                    val c = j + k * dir[1]
                    if (r in 0 until BOARD_SIZE && c in 0 until BOARD_SIZE) {
                        if (board[r][c] == player) {
                            countPlayer++
                        } else if (board[r][c] == opponent) {
                            countOpponent++
                        }
                        association = association * 10 + board[r][c]
                    } else {
                        break
                    }
                }
                score += when(association){
                    22222 -> 50000 // 活五
                    22220, 22202, 22022, 20222 -> 10000 // 活四
                    122220, 122202, 122022, 120222, 102222, 22221 -> 5000 // 冲四
                    222, 2202, 2022, 2220 -> 2000 // 活三
                    12220, 12202, 12022, 10222, 2221 -> 1000 // 眠三
                    22, 202, 20 -> 500 // 活二
                    1220, 1202, 1020, 210, 2120 -> 200 // 眠二
                    else -> 0
                }
            }
        }
    }

    return score
}

// Minimax 算法
fun minimax(board: Array<Array<Int>>, depth: Int, player: Int): Int {
    if (depth == 0) {
        return evaluate(board,player)
    }
    var bestScore = 0
    val opponent = if (player == 2) 1 else 2
    for (i in 0 until BOARD_SIZE) {
        for (j in 0 until BOARD_SIZE) {
            if (board[i][j] == 0) {
                board[i][j] = opponent
                val score = minimax(board, depth - 1, opponent)
                board[i][j] = 0
                bestScore = maxOf(bestScore, score)
            }
        }
    }

    return bestScore
}

// 寻找最佳下棋位置
fun findBestMove(board: Array<Array<Int>>,player: Int): Pair<Int, Int> {
    var bestScore = Int.MIN_VALUE
    var bestMove = Pair(-1, -1)

    for (i in 0 until BOARD_SIZE) {
        for (j in 0 until BOARD_SIZE) {
            if (board[i][j] == 0) {
                board[i][j] = player // 模拟落子
                var score = minimax(board, 3, player) // 这里设定最大搜索深度为3
                score = score * major[i][j] + major[i][j]  // 位置价值
                board[i][j] = 0 // 撤销落子
                if (score > bestScore) {
                    bestScore = score // 更新最高分
                    bestMove = Pair(i, j) // 更新最佳落子位置
                }
            }
        }
    }

    return bestMove
}
// 初始化位置价值矩阵
fun initMatrix(matrix:Array<Array<Int>>){
    val centerX = matrix.size / 2
    val centerY = matrix.size / 2
    for (i in matrix.indices) {
        for (j in matrix.indices) {
            val distance = abs(i - centerX) + abs(j - centerY)
            matrix[i][j] = matrix.size - distance
        }
    }
}
// 位置价值矩阵
val major = Array(BOARD_SIZE) { Array(BOARD_SIZE) { 0 } }

// 主函数
fun main() {

    initMatrix(major)

    val board = Array(BOARD_SIZE) { Array(BOARD_SIZE) { 0 } }
    // 模拟当前棋盘状态
    val scan = Scanner(System.`in`)
    while (true){
        // ...
        val (x,y) = findBestMove(board,2)
        board[x][y] = 2
        println("Best Move: ${x}, $y")
        for (i in board.indices){
            println(board[i].contentToString())
        }

        val p = scan.nextLine().split(",")
        board[p[0].toInt()][p[1].toInt()] = 1
    }
}

Compiled from "Test.kt"
public final class TestKt {
  public static final int BOARD_SIZE;

  private static final java.lang.Integer[][] major;

  public static final int evaluate(java.lang.Integer[][], int);
    Code:
       0: aload_0
       1: ldc           #9                  // String board
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: iconst_2
       8: if_icmpne     15
      11: iconst_1
      12: goto          16
      15: iconst_2
      16: istore_2
      17: iconst_0
      18: istore_3
      19: iconst_0
      20: istore        4
      22: iload         4
      24: bipush        15
      26: if_icmpge     706
      29: iconst_0
      30: istore        5
      32: iload         5
      34: bipush        15
      36: if_icmpge     700
      39: bipush        8
      41: anewarray     #17                 // class "[I"
      44: astore        7
      46: aload         7
      48: iconst_0
      49: iconst_2
      50: newarray       int
      52: astore        8
      54: aload         8
      56: iconst_0
      57: iconst_1
      58: iastore
      59: aload         8
      61: iconst_1
      62: iconst_0
      63: iastore
      64: aload         8
      66: aastore
      67: aload         7
      69: iconst_1
      70: iconst_2
      71: newarray       int
      73: astore        8
      75: aload         8
      77: iconst_0
      78: iconst_1
      79: iastore
      80: aload         8
      82: iconst_1
      83: iconst_m1
      84: iastore
      85: aload         8
      87: aastore
      88: aload         7
      90: iconst_2
      91: iconst_2
      92: newarray       int
      94: astore        8
      96: aload         8
      98: iconst_0
      99: iconst_0
     100: iastore
     101: aload         8
     103: iconst_1
     104: iconst_m1
     105: iastore
     106: aload         8
     108: aastore
     109: aload         7
     111: iconst_3
     112: iconst_2
     113: newarray       int
     115: astore        8
     117: aload         8
     119: iconst_0
     120: iconst_m1
     121: iastore
     122: aload         8
     124: iconst_1
     125: iconst_m1
     126: iastore
     127: aload         8
     129: aastore
     130: aload         7
     132: iconst_4
     133: iconst_2
     134: newarray       int
     136: astore        8
     138: aload         8
     140: iconst_0
     141: iconst_m1
     142: iastore
     143: aload         8
     145: iconst_1
     146: iconst_0
     147: iastore
     148: aload         8
     150: aastore
     151: aload         7
     153: iconst_5
     154: iconst_2
     155: newarray       int
     157: astore        8
     159: aload         8
     161: iconst_0
     162: iconst_m1
     163: iastore
     164: aload         8
     166: iconst_1
     167: iconst_1
     168: iastore
     169: aload         8
     171: aastore
     172: aload         7
     174: bipush        6
     176: iconst_2
     177: newarray       int
     179: astore        8
     181: aload         8
     183: iconst_0
     184: iconst_0
     185: iastore
     186: aload         8
     188: iconst_1
     189: iconst_1
     190: iastore
     191: aload         8
     193: aastore
     194: aload         7
     196: bipush        7
     198: iconst_2
     199: newarray       int
     201: astore        8
     203: aload         8
     205: iconst_0
     206: iconst_1
     207: iastore
     208: aload         8
     210: iconst_1
     211: iconst_1
     212: iastore
     213: aload         8
     215: aastore
     216: aload         7
     218: astore        6
     220: iconst_0
     221: istore        7
     223: aload         6
     225: checkcast     #19                 // class "[Ljava/lang/Object;"
     228: arraylength
     229: istore        8
     231: iload         7
     233: iload         8
     235: if_icmpge     694
     238: aload         6
     240: iload         7
     242: aaload
     243: astore        9
     245: iconst_0
     246: istore        10
     248: iconst_0
     249: istore        11
     251: iconst_0
     252: istore        12
     254: iconst_0
     255: istore        13
     257: iload         13
     259: bipush        6
     261: if_icmpge     405
     264: iload         4
     266: iload         13
     268: aload         9
     270: iconst_0
     271: iaload
     272: imul
     273: iadd
     274: istore        14
     276: iload         5
     278: iload         13
     280: aload         9
     282: iconst_1
     283: iaload
     284: imul
     285: iadd
     286: istore        15
     288: iconst_0
     289: iload         14
     291: if_icmpgt     309
     294: iload         14
     296: bipush        15
     298: if_icmpge     305
     301: iconst_1
     302: goto          310
     305: iconst_0
     306: goto          310
     309: iconst_0
     310: ifeq          396
     313: iconst_0
     314: iload         15
     316: if_icmpgt     334
     319: iload         15
     321: bipush        15
     323: if_icmpge     330
     326: iconst_1
     327: goto          335
     330: iconst_0
     331: goto          335
     334: iconst_0
     335: ifeq          396
     338: aload_0
     339: iload         14
     341: aaload
     342: iload         15
     344: aaload
     345: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
     348: iload_1
     349: if_icmpne     358
     352: iinc          10, 1
     355: goto          375
     358: aload_0
     359: iload         14
     361: aaload
     362: iload         15
     364: aaload
     365: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
     368: iload_2
     369: if_icmpne     375
     372: iinc          11, 1
     375: iload         12
     377: bipush        10
     379: imul
     380: aload_0
     381: iload         14
     383: aaload
     384: iload         15
     386: aaload
     387: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
     390: iadd
     391: istore        12
     393: goto          399
     396: goto          405
     399: iinc          13, 1
     402: goto          257
     405: iload_3
     406: iload         12
     408: lookupswitch  { // 28
                    20: 673
                    22: 673
                   202: 673
                   210: 679
                   222: 661
                  1020: 679
                  1202: 679
                  1220: 679
                  2022: 661
                  2120: 679
                  2202: 661
                  2220: 661
                  2221: 667
                 10222: 667
                 12022: 667
                 12202: 667
                 12220: 667
                 20222: 649
                 22022: 649
                 22202: 649
                 22220: 649
                 22221: 655
                 22222: 644
                102222: 655
                120222: 655
                122022: 655
                122202: 655
                122220: 655
               default: 685
          }
     644: ldc           #26                 // int 50000
     646: goto          686
     649: sipush        10000
     652: goto          686
     655: sipush        5000
     658: goto          686
     661: sipush        2000
     664: goto          686
     667: sipush        1000
     670: goto          686
     673: sipush        500
     676: goto          686
     679: sipush        200
     682: goto          686
     685: iconst_0
     686: iadd
     687: istore_3
     688: iinc          7, 1
     691: goto          231
     694: iinc          5, 1
     697: goto          32
     700: iinc          4, 1
     703: goto          22
     706: iload_3
     707: ireturn

  public static final int minimax(java.lang.Integer[][], int, int);
    Code:
       0: aload_0
       1: ldc           #9                  // String board
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: ifne          16
      10: aload_0
      11: iload_2
      12: invokestatic  #48                 // Method evaluate:([[Ljava/lang/Integer;I)I
      15: ireturn
      16: iconst_0
      17: istore_3
      18: iload_2
      19: iconst_2
      20: if_icmpne     27
      23: iconst_1
      24: goto          28
      27: iconst_2
      28: istore        4
      30: iconst_0
      31: istore        5
      33: iload         5
      35: bipush        15
      37: if_icmpge     116
      40: iconst_0
      41: istore        6
      43: iload         6
      45: bipush        15
      47: if_icmpge     110
      50: aload_0
      51: iload         5
      53: aaload
      54: iload         6
      56: aaload
      57: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
      60: ifne          104
      63: aload_0
      64: iload         5
      66: aaload
      67: iload         6
      69: iload         4
      71: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      74: aastore
      75: aload_0
      76: iload_1
      77: iconst_1
      78: isub
      79: iload         4
      81: invokestatic  #54                 // Method minimax:([[Ljava/lang/Integer;II)I
      84: istore        7
      86: aload_0
      87: iload         5
      89: aaload
      90: iload         6
      92: iconst_0
      93: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      96: aastore
      97: iload_3
      98: iload         7
     100: invokestatic  #60                 // Method java/lang/Math.max:(II)I
     103: istore_3
     104: iinc          6, 1
     107: goto          43
     110: iinc          5, 1
     113: goto          33
     116: iload_3
     117: ireturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> findBestMove(java.lang.Integer[][], int);
    Code:
       0: aload_0
       1: ldc           #9                  // String board
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #66                 // int -2147483648
       8: istore_2
       9: new           #68                 // class kotlin/Pair
      12: dup
      13: iconst_m1
      14: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: iconst_m1
      18: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      21: invokespecial #72                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      24: astore_3
      25: iconst_0
      26: istore        4
      28: iload         4
      30: bipush        15
      32: if_icmpge     157
      35: iconst_0
      36: istore        5
      38: iload         5
      40: bipush        15
      42: if_icmpge     151
      45: aload_0
      46: iload         4
      48: aaload
      49: iload         5
      51: aaload
      52: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
      55: ifne          145
      58: aload_0
      59: iload         4
      61: aaload
      62: iload         5
      64: iload_1
      65: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      68: aastore
      69: aload_0
      70: iconst_3
      71: iload_1
      72: invokestatic  #54                 // Method minimax:([[Ljava/lang/Integer;II)I
      75: istore        6
      77: iload         6
      79: getstatic     #75                 // Field major:[[Ljava/lang/Integer;
      82: iload         4
      84: aaload
      85: iload         5
      87: aaload
      88: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
      91: imul
      92: getstatic     #75                 // Field major:[[Ljava/lang/Integer;
      95: iload         4
      97: aaload
      98: iload         5
     100: aaload
     101: invokevirtual #25                 // Method java/lang/Integer.intValue:()I
     104: iadd
     105: istore        6
     107: aload_0
     108: iload         4
     110: aaload
     111: iload         5
     113: iconst_0
     114: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     117: aastore
     118: iload         6
     120: iload_2
     121: if_icmple     145
     124: iload         6
     126: istore_2
     127: new           #68                 // class kotlin/Pair
     130: dup
     131: iload         4
     133: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     136: iload         5
     138: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: invokespecial #72                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     144: astore_3
     145: iinc          5, 1
     148: goto          38
     151: iinc          4, 1
     154: goto          28
     157: aload_3
     158: areturn

  public static final void initMatrix(java.lang.Integer[][]);
    Code:
       0: aload_0
       1: ldc           #81                 // String matrix
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #19                 // class "[Ljava/lang/Object;"
      10: arraylength
      11: iconst_2
      12: idiv
      13: istore_1
      14: aload_0
      15: checkcast     #19                 // class "[Ljava/lang/Object;"
      18: arraylength
      19: iconst_2
      20: idiv
      21: istore_2
      22: iconst_0
      23: istore_3
      24: aload_0
      25: checkcast     #19                 // class "[Ljava/lang/Object;"
      28: arraylength
      29: istore        4
      31: iload_3
      32: iload         4
      34: if_icmpge     99
      37: iconst_0
      38: istore        5
      40: aload_0
      41: checkcast     #19                 // class "[Ljava/lang/Object;"
      44: arraylength
      45: istore        6
      47: iload         5
      49: iload         6
      51: if_icmpge     93
      54: iload_3
      55: iload_1
      56: isub
      57: invokestatic  #85                 // Method java/lang/Math.abs:(I)I
      60: iload         5
      62: iload_2
      63: isub
      64: invokestatic  #85                 // Method java/lang/Math.abs:(I)I
      67: iadd
      68: istore        7
      70: aload_0
      71: iload_3
      72: aaload
      73: iload         5
      75: aload_0
      76: checkcast     #19                 // class "[Ljava/lang/Object;"
      79: arraylength
      80: iload         7
      82: isub
      83: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      86: aastore
      87: iinc          5, 1
      90: goto          47
      93: iinc          3, 1
      96: goto          31
      99: return

  public static final java.lang.Integer[][] getMajor();
    Code:
       0: getstatic     #75                 // Field major:[[Ljava/lang/Integer;
       3: areturn

  public static final void main();
    Code:
       0: getstatic     #75                 // Field major:[[Ljava/lang/Integer;
       3: invokestatic  #94                 // Method initMatrix:([[Ljava/lang/Integer;)V
       6: iconst_0
       7: istore_1
       8: bipush        15
      10: anewarray     #96                 // class "[Ljava/lang/Integer;"
      13: astore_2
      14: iload_1
      15: bipush        15
      17: if_icmpge     77
      20: iload_1
      21: istore_3
      22: aload_2
      23: iload_3
      24: iconst_0
      25: istore        4
      27: bipush        15
      29: anewarray     #21                 // class java/lang/Integer
      32: astore        5
      34: istore        9
      36: astore        8
      38: iload         4
      40: bipush        15
      42: if_icmpge     64
      45: iload         4
      47: istore        6
      49: aload         5
      51: iload         6
      53: iconst_0
      54: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: aastore
      58: iinc          4, 1
      61: goto          38
      64: aload         8
      66: iload         9
      68: aload         5
      70: aastore
      71: iinc          1, 1
      74: goto          14
      77: aload_2
      78: astore_0
      79: new           #98                 // class java/util/Scanner
      82: dup
      83: getstatic     #104                // Field java/lang/System.in:Ljava/io/InputStream;
      86: invokespecial #107                // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      89: astore_1
      90: nop
      91: aload_0
      92: iconst_2
      93: invokestatic  #109                // Method findBestMove:([[Ljava/lang/Integer;I)Lkotlin/Pair;
      96: astore_2
      97: aload_2
      98: invokevirtual #113                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     101: checkcast     #115                // class java/lang/Number
     104: invokevirtual #116                // Method java/lang/Number.intValue:()I
     107: istore_3
     108: aload_2
     109: invokevirtual #119                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     112: checkcast     #115                // class java/lang/Number
     115: invokevirtual #116                // Method java/lang/Number.intValue:()I
     118: istore        4
     120: aload_0
     121: iload_3
     122: aaload
     123: iload         4
     125: iconst_2
     126: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: aastore
     130: new           #121                // class java/lang/StringBuilder
     133: dup
     134: invokespecial #123                // Method java/lang/StringBuilder."<init>":()V
     137: ldc           #125                // String Best Move:
     139: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     142: iload_3
     143: invokevirtual #132                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     146: ldc           #134                // String ,
     148: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     151: iload         4
     153: invokevirtual #132                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     156: invokevirtual #138                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     159: getstatic     #142                // Field java/lang/System.out:Ljava/io/PrintStream;
     162: swap
     163: invokevirtual #148                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     166: iconst_0
     167: istore        5
     169: aload_0
     170: checkcast     #19                 // class "[Ljava/lang/Object;"
     173: arraylength
     174: istore        6
     176: iload         5
     178: iload         6
     180: if_icmpge     212
     183: aload_0
     184: iload         5
     186: aaload
     187: invokestatic  #153                // Method java/util/Arrays.toString:([Ljava/lang/Object;)Ljava/lang/String;
     190: dup
     191: ldc           #155                // String toString(...)
     193: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     196: astore        7
     198: getstatic     #142                // Field java/lang/System.out:Ljava/io/PrintStream;
     201: aload         7
     203: invokevirtual #148                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     206: iinc          5, 1
     209: goto          176
     212: aload_1
     213: invokevirtual #161                // Method java/util/Scanner.nextLine:()Ljava/lang/String;
     216: dup
     217: ldc           #163                // String nextLine(...)
     219: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     222: checkcast     #165                // class java/lang/CharSequence
     225: iconst_1
     226: anewarray     #167                // class java/lang/String
     229: astore        6
     231: aload         6
     233: iconst_0
     234: ldc           #169                // String ,
     236: aastore
     237: aload         6
     239: iconst_0
     240: iconst_0
     241: bipush        6
     243: aconst_null
     244: invokestatic  #175                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     247: astore        5
     249: aload_0
     250: aload         5
     252: iconst_0
     253: invokeinterface #181,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     258: checkcast     #167                // class java/lang/String
     261: invokestatic  #185                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     264: aaload
     265: aload         5
     267: iconst_1
     268: invokeinterface #181,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     273: checkcast     #167                // class java/lang/String
     276: invokestatic  #185                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     279: iconst_1
     280: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: aastore
     284: goto          90

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

  static {};
    Code:
       0: iconst_0
       1: istore_0
       2: bipush        15
       4: anewarray     #96                 // class "[Ljava/lang/Integer;"
       7: astore_1
       8: iload_0
       9: bipush        15
      11: if_icmpge     68
      14: iload_0
      15: istore_2
      16: aload_1
      17: iload_2
      18: iconst_0
      19: istore_3
      20: bipush        15
      22: anewarray     #21                 // class java/lang/Integer
      25: astore        4
      27: istore        7
      29: astore        6
      31: iload_3
      32: bipush        15
      34: if_icmpge     55
      37: iload_3
      38: istore        5
      40: aload         4
      42: iload         5
      44: iconst_0
      45: invokestatic  #52                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: aastore
      49: iinc          3, 1
      52: goto          31
      55: aload         6
      57: iload         7
      59: aload         4
      61: aastore
      62: iinc          0, 1
      65: goto          8
      68: aload_1
      69: putstatic     #75                 // Field major:[[Ljava/lang/Integer;
      72: return
}


class SubArray {

    fun getLengthOfLongestContiguousSubarray(array: Array<Int>): Int {
        var maxLength = 1
        for (i in 0 until array.size - 1) {
            var minimum = array[i]
            var maximum = array[i]

            for (j in i + 1 until array.size) {
                minimum = Math.min(minimum, array[j])
                maximum = Math.max(maximum, array[j])

                if (maximum - minimum == j - i) {
                    maxLength = Math.max(maxLength, maximum - minimum + 1)
                }
            }
        }
        return maxLength
    }

    fun getSmallestPositiveNumber(array: Array<Int>): Int {
        var result = 1
        var i = 0
        while (i < array.size && array[i] <= result) {
            result += array[i]
            i++
        }
        return result
    }

    fun getSmallestSubarrayWithSumGreaterThanValue(array: Array<Int>, value: Int): Int {
        var minLength = array.size + 1

        for (start in 0 until array.size) {
            // Initialize sum starting with current start
            var sum = array[start]

            // If first element itself is greater
            if (sum > value) {
                return 1
            }

            for (end in start + 1 until array.size) {
                sum += array[end]

                // If sum becomes more than x and length of
                // this subarray is smaller than current smallest
                // length, update the smallest length (or result)
                val length = end - start + 1
                if (sum > value && length < minLength) {
                    minLength = length
                }
            }
        }
        return minLength
    }
}

Compiled from "SubArray.kt"
public final class SubArray {
  public SubArray();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int getLengthOfLongestContiguousSubarray(java.lang.Integer[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String array
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore_2
       8: iconst_0
       9: istore_3
      10: aload_1
      11: arraylength
      12: iconst_1
      13: isub
      14: istore        4
      16: iload_3
      17: iload         4
      19: if_icmpge     118
      22: aload_1
      23: iload_3
      24: aaload
      25: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      28: istore        5
      30: aload_1
      31: iload_3
      32: aaload
      33: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      36: istore        6
      38: iload_3
      39: iconst_1
      40: iadd
      41: istore        7
      43: aload_1
      44: arraylength
      45: istore        8
      47: iload         7
      49: iload         8
      51: if_icmpge     112
      54: iload         5
      56: aload_1
      57: iload         7
      59: aaload
      60: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      63: invokestatic  #33                 // Method java/lang/Math.min:(II)I
      66: istore        5
      68: iload         6
      70: aload_1
      71: iload         7
      73: aaload
      74: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      77: invokestatic  #36                 // Method java/lang/Math.max:(II)I
      80: istore        6
      82: iload         6
      84: iload         5
      86: isub
      87: iload         7
      89: iload_3
      90: isub
      91: if_icmpne     106
      94: iload_2
      95: iload         6
      97: iload         5
      99: isub
     100: iconst_1
     101: iadd
     102: invokestatic  #36                 // Method java/lang/Math.max:(II)I
     105: istore_2
     106: iinc          7, 1
     109: goto          47
     112: iinc          3, 1
     115: goto          16
     118: iload_2
     119: ireturn

  public final int getSmallestPositiveNumber(java.lang.Integer[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String array
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore_2
       8: iconst_0
       9: istore_3
      10: iload_3
      11: aload_1
      12: arraylength
      13: if_icmpge     41
      16: aload_1
      17: iload_3
      18: aaload
      19: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      22: iload_2
      23: if_icmpgt     41
      26: iload_2
      27: aload_1
      28: iload_3
      29: aaload
      30: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      33: iadd
      34: istore_2
      35: iinc          3, 1
      38: goto          10
      41: iload_2
      42: ireturn

  public final int getSmallestSubarrayWithSumGreaterThanValue(java.lang.Integer[], int);
    Code:
       0: aload_1
       1: ldc           #15                 // String array
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: iconst_1
       9: iadd
      10: istore_3
      11: iconst_0
      12: istore        4
      14: aload_1
      15: arraylength
      16: istore        5
      18: iload         4
      20: iload         5
      22: if_icmpge     107
      25: aload_1
      26: iload         4
      28: aaload
      29: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      32: istore        6
      34: iload         6
      36: iload_2
      37: if_icmple     42
      40: iconst_1
      41: ireturn
      42: iload         4
      44: iconst_1
      45: iadd
      46: istore        7
      48: aload_1
      49: arraylength
      50: istore        8
      52: iload         7
      54: iload         8
      56: if_icmpge     101
      59: iload         6
      61: aload_1
      62: iload         7
      64: aaload
      65: invokevirtual #27                 // Method java/lang/Integer.intValue:()I
      68: iadd
      69: istore        6
      71: iload         7
      73: iload         4
      75: isub
      76: iconst_1
      77: iadd
      78: istore        9
      80: iload         6
      82: iload_2
      83: if_icmple     95
      86: iload         9
      88: iload_3
      89: if_icmpge     95
      92: iload         9
      94: istore_3
      95: iinc          7, 1
      98: goto          52
     101: iinc          4, 1
     104: goto          18
     107: iload_3
     108: ireturn
}


import java.lang.Integer.max
import java.lang.Integer.min
import kotlin.math.abs

enum class Function {
    CHECK, PLACE
}

enum class Player {
    PLAYER1, PLAYER2
}

data class Position(
    val col: Int,
    val row: Int
)

data class Ship(
    var parts: List<Position>
)

typealias Field = Array<Array<Int>>

data class GameState(
    val field1: Field,
    val field2: Field,
    val ships1: List<Ship>,
    val ships2: List<Ship>
)

fun main() {
    var gameState = createGameState()
    showField(gameState, Player.PLAYER1)

    while (true) {
        print("Enter ship coordinates: ")
        gameState = place(gameState, Player.PLAYER1)
        showField(gameState, Player.PLAYER1)
    }
}

fun createGameState(): GameState {
    val field1 = Array(10) { Array(10) { 0 } }
    val field2 = Array(10) { Array(10) { 0 } }

    return GameState(field1, field2, emptyList(), emptyList())
}

fun showField(gameState: GameState, player: Player) {
    for (row in '0'..'9') {
        print("\t  $row")
    }
    println()

    val tabVertLine = "\t${9474.toChar()}"

    val ships = if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2

    for (col in 0 until 10) {
        print(" " + (col + 65).toChar() + tabVertLine)
        for (row in 0 until 10) {
            var shipFound = false
            ships.forEach {
                it.parts.forEach {
                    if (it.row == row && it.col == col) {
                        shipFound = true
                    }
                }
            }
            if (shipFound) {
                print("██")
            }
            print(tabVertLine)
        }
        println()
    }
}

fun place(gameState: GameState, player: Player): GameState {
    val location = readln().lowercase()
    println("inside place")

    val ships = (if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2).toMutableList()

    if (inputIsValid(Function.PLACE, location)) {
        val coordinates = convertPair(location)
        val firstPos =
            Pair(min(coordinates.first.row, coordinates.second.row), min(coordinates.first.col, coordinates.second.col))
        val lastPos =
            Pair(max(coordinates.first.row, coordinates.second.row), max(coordinates.first.col, coordinates.second.col))

        println(coordinates)

        val n = mutableListOf<Position>()

        for (row in firstPos.first..lastPos.first) {
            for (col in firstPos.second..lastPos.second) {
                if (isCellOccupied(gameState, player, Position(col, row))) {
                    println("This cell is occupied")
                    return gameState
                } else {
                    println("set at $row,$col")
                    n.add(Position(col, row))
                }
            }
        }
        ships.addLast(Ship(n))
    }
    return if (player == Player.PLAYER1) {
        gameState.copy(ships1 = ships)
    } else {
        gameState.copy(ships2 = ships)
    }
}

fun isCellOccupied(gameState: GameState, player: Player, position: Position): Boolean {
    val ships = if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2

    return ships.any { ship -> ship.parts.any { it == position } }
}

fun convertPair(input: String): Pair<Position, Position> {
    println("in convertPair $input")
    return Pair(convert(input.substring(0, 2)), convert(input.substring(2, 4)))
}

fun convert(input: String): Position {
    println("in convert $input")
    val rowChar = input[0]
    val columnChar = input[1]

    val row = rowChar - 'a'
    val column = columnChar.toString().toInt()

    return Position(row, column)
}

fun check() {
    val pos = readln().lowercase()
    if (inputIsValid(Function.CHECK, pos)) {

    }
}

fun inputIsValid(function: Function, input: String): Boolean {
    println(function)
    when (function) {
        Function.CHECK -> {
            if (input.length == 2 && input[0] in 'a'..'j' && input[1] in '0'..'9') {
                return true
            } else {
                println("Enter the cell index in format \"letternumber\", for example \"a0a3\"")
                return false
            }
        }

        Function.PLACE -> {
            if (input.length == 4 &&
                input[0] in 'a'..'j' && input[1] in '0'..'9' &&
                input[2] in 'a'..'j' && input[3] in '0'..'9' &&
                (input[0] == input[2] || input[1] == input[3]) &&
                abs(input[0] - input[2]) <= 3 &&
                abs(input[1] - input[3]) <= 3
            ) {
                return true
            } else {
                println("Enter the cell indexes in format \"letternumberletternumber\" for placing ship, for example \"a0b0\"")
                return false
            }
        }
    }
}

Compiled from "Main.kt"
public final class MainKt$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  static {};
    Code:
       0: invokestatic  #14                 // Method Function.values:()[LFunction;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Function.CHECK:LFunction;
      12: invokevirtual #22                 // Method Function.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Function.PLACE:LFunction;
      26: invokevirtual #22                 // Method Function.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: aload_0
      36: putstatic     #29                 // Field $EnumSwitchMapping$0:[I
      39: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
}

Compiled from "Main.kt"
public final class MainKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method createGameState:()LGameState;
       3: astore_0
       4: aload_0
       5: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
       8: invokestatic  #20                 // Method showField:(LGameState;LPlayer;)V
      11: nop
      12: ldc           #22                 // String Enter ship coordinates:
      14: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      17: swap
      18: invokevirtual #34                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      21: aload_0
      22: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
      25: invokestatic  #38                 // Method place:(LGameState;LPlayer;)LGameState;
      28: astore_0
      29: aload_0
      30: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
      33: invokestatic  #20                 // Method showField:(LGameState;LPlayer;)V
      36: goto          11

  public static final GameState createGameState();
    Code:
       0: iconst_0
       1: istore_1
       2: bipush        10
       4: anewarray     #45                 // class "[Ljava/lang/Integer;"
       7: astore_2
       8: iload_1
       9: bipush        10
      11: if_icmpge     71
      14: iload_1
      15: istore_3
      16: aload_2
      17: iload_3
      18: iconst_0
      19: istore        4
      21: bipush        10
      23: anewarray     #47                 // class java/lang/Integer
      26: astore        5
      28: istore        9
      30: astore        8
      32: iload         4
      34: bipush        10
      36: if_icmpge     58
      39: iload         4
      41: istore        6
      43: aload         5
      45: iload         6
      47: iconst_0
      48: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      51: aastore
      52: iinc          4, 1
      55: goto          32
      58: aload         8
      60: iload         9
      62: aload         5
      64: aastore
      65: iinc          1, 1
      68: goto          8
      71: aload_2
      72: astore_0
      73: iconst_0
      74: istore_2
      75: bipush        10
      77: anewarray     #45                 // class "[Ljava/lang/Integer;"
      80: astore_3
      81: iload_2
      82: bipush        10
      84: if_icmpge     146
      87: iload_2
      88: istore        4
      90: aload_3
      91: iload         4
      93: iconst_0
      94: istore        5
      96: bipush        10
      98: anewarray     #47                 // class java/lang/Integer
     101: astore        6
     103: istore        9
     105: astore        8
     107: iload         5
     109: bipush        10
     111: if_icmpge     133
     114: iload         5
     116: istore        7
     118: aload         6
     120: iload         7
     122: iconst_0
     123: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     126: aastore
     127: iinc          5, 1
     130: goto          107
     133: aload         8
     135: iload         9
     137: aload         6
     139: aastore
     140: iinc          2, 1
     143: goto          81
     146: aload_3
     147: astore_1
     148: new           #42                 // class GameState
     151: dup
     152: aload_0
     153: aload_1
     154: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     157: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     160: invokespecial #61                 // Method GameState."<init>":([[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;)V
     163: areturn

  public static final void showField(GameState, Player);
    Code:
       0: aload_0
       1: ldc           #66                 // String gameState
       3: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #74                 // String player
       9: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: bipush        48
      14: istore_2
      15: iload_2
      16: bipush        58
      18: if_icmpge     55
      21: new           #76                 // class java/lang/StringBuilder
      24: dup
      25: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
      28: ldc           #80                 // String \t
      30: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      33: iload_2
      34: invokevirtual #87                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      37: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      40: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      43: swap
      44: invokevirtual #34                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      47: iload_2
      48: iconst_1
      49: iadd
      50: i2c
      51: istore_2
      52: goto          15
      55: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      58: invokevirtual #94                 // Method java/io/PrintStream.println:()V
      61: ldc           #96                 // String \t│
      63: astore_2
      64: aload_1
      65: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
      68: if_acmpne     78
      71: aload_0
      72: invokevirtual #99                 // Method GameState.getShips1:()Ljava/util/List;
      75: goto          82
      78: aload_0
      79: invokevirtual #102                // Method GameState.getShips2:()Ljava/util/List;
      82: astore_3
      83: iconst_0
      84: istore        4
      86: iload         4
      88: bipush        10
      90: if_icmpge     313
      93: new           #76                 // class java/lang/StringBuilder
      96: dup
      97: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
     100: bipush        32
     102: invokevirtual #87                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     105: iload         4
     107: bipush        65
     109: iadd
     110: i2c
     111: invokevirtual #87                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     114: aload_2
     115: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     118: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     121: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     124: swap
     125: invokevirtual #34                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     128: iconst_0
     129: istore        5
     131: iload         5
     133: bipush        10
     135: if_icmpge     301
     138: iconst_0
     139: istore        6
     141: aload_3
     142: checkcast     #104                // class java/lang/Iterable
     145: astore        7
     147: iconst_0
     148: istore        8
     150: aload         7
     152: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     157: astore        9
     159: aload         9
     161: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     166: ifeq          273
     169: aload         9
     171: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     176: astore        10
     178: aload         10
     180: checkcast     #120                // class Ship
     183: astore        11
     185: iconst_0
     186: istore        12
     188: aload         11
     190: invokevirtual #123                // Method Ship.getParts:()Ljava/util/List;
     193: checkcast     #104                // class java/lang/Iterable
     196: astore        13
     198: iconst_0
     199: istore        14
     201: aload         13
     203: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     208: astore        15
     210: aload         15
     212: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     217: ifeq          267
     220: aload         15
     222: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     227: astore        16
     229: aload         16
     231: checkcast     #125                // class Position
     234: astore        17
     236: iconst_0
     237: istore        18
     239: aload         17
     241: invokevirtual #129                // Method Position.getRow:()I
     244: iload         5
     246: if_icmpne     262
     249: aload         17
     251: invokevirtual #132                // Method Position.getCol:()I
     254: iload         4
     256: if_icmpne     262
     259: iconst_1
     260: istore        6
     262: nop
     263: nop
     264: goto          210
     267: nop
     268: nop
     269: nop
     270: goto          159
     273: nop
     274: iload         6
     276: ifeq          288
     279: ldc           #134                // String ██
     281: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     284: swap
     285: invokevirtual #34                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     288: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     291: aload_2
     292: invokevirtual #34                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     295: iinc          5, 1
     298: goto          131
     301: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     304: invokevirtual #94                 // Method java/io/PrintStream.println:()V
     307: iinc          4, 1
     310: goto          86
     313: return

  public static final GameState place(GameState, Player);
    Code:
       0: aload_0
       1: ldc           #66                 // String gameState
       3: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #74                 // String player
       9: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: invokestatic  #163                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      15: getstatic     #169                // Field java/util/Locale.ROOT:Ljava/util/Locale;
      18: invokevirtual #173                // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      21: dup
      22: ldc           #175                // String toLowerCase(...)
      24: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      27: astore_2
      28: ldc           #180                // String inside place
      30: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      37: aload_1
      38: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
      41: if_acmpne     51
      44: aload_0
      45: invokevirtual #99                 // Method GameState.getShips1:()Ljava/util/List;
      48: goto          55
      51: aload_0
      52: invokevirtual #102                // Method GameState.getShips2:()Ljava/util/List;
      55: checkcast     #184                // class java/util/Collection
      58: invokestatic  #188                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      61: astore_3
      62: getstatic     #194                // Field Function.PLACE:LFunction;
      65: aload_2
      66: invokestatic  #198                // Method inputIsValid:(LFunction;Ljava/lang/String;)Z
      69: ifeq          421
      72: aload_2
      73: invokestatic  #202                // Method convertPair:(Ljava/lang/String;)Lkotlin/Pair;
      76: astore        4
      78: new           #204                // class kotlin/Pair
      81: dup
      82: aload         4
      84: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      87: checkcast     #125                // class Position
      90: invokevirtual #129                // Method Position.getRow:()I
      93: aload         4
      95: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      98: checkcast     #125                // class Position
     101: invokevirtual #129                // Method Position.getRow:()I
     104: invokestatic  #214                // Method java/lang/Integer.min:(II)I
     107: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     110: aload         4
     112: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     115: checkcast     #125                // class Position
     118: invokevirtual #132                // Method Position.getCol:()I
     121: aload         4
     123: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     126: checkcast     #125                // class Position
     129: invokevirtual #132                // Method Position.getCol:()I
     132: invokestatic  #214                // Method java/lang/Integer.min:(II)I
     135: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     138: invokespecial #217                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     141: astore        5
     143: new           #204                // class kotlin/Pair
     146: dup
     147: aload         4
     149: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     152: checkcast     #125                // class Position
     155: invokevirtual #129                // Method Position.getRow:()I
     158: aload         4
     160: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     163: checkcast     #125                // class Position
     166: invokevirtual #129                // Method Position.getRow:()I
     169: invokestatic  #220                // Method java/lang/Integer.max:(II)I
     172: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     175: aload         4
     177: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     180: checkcast     #125                // class Position
     183: invokevirtual #132                // Method Position.getCol:()I
     186: aload         4
     188: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     191: checkcast     #125                // class Position
     194: invokevirtual #132                // Method Position.getCol:()I
     197: invokestatic  #220                // Method java/lang/Integer.max:(II)I
     200: invokestatic  #51                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     203: invokespecial #217                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     206: astore        6
     208: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     211: aload         4
     213: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     216: new           #222                // class java/util/ArrayList
     219: dup
     220: invokespecial #223                // Method java/util/ArrayList."<init>":()V
     223: checkcast     #158                // class java/util/List
     226: astore        7
     228: aload         5
     230: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     233: checkcast     #225                // class java/lang/Number
     236: invokevirtual #228                // Method java/lang/Number.intValue:()I
     239: istore        8
     241: aload         6
     243: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     246: checkcast     #225                // class java/lang/Number
     249: invokevirtual #228                // Method java/lang/Number.intValue:()I
     252: istore        9
     254: iload         8
     256: iload         9
     258: if_icmpgt     406
     261: aload         5
     263: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     266: checkcast     #225                // class java/lang/Number
     269: invokevirtual #228                // Method java/lang/Number.intValue:()I
     272: istore        10
     274: aload         6
     276: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     279: checkcast     #225                // class java/lang/Number
     282: invokevirtual #228                // Method java/lang/Number.intValue:()I
     285: istore        11
     287: iload         10
     289: iload         11
     291: if_icmpgt     393
     294: aload_0
     295: aload_1
     296: new           #125                // class Position
     299: dup
     300: iload         10
     302: iload         8
     304: invokespecial #231                // Method Position."<init>":(II)V
     307: invokestatic  #235                // Method isCellOccupied:(LGameState;LPlayer;LPosition;)Z
     310: ifeq          324
     313: ldc           #237                // String This cell is occupied
     315: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     318: swap
     319: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     322: aload_0
     323: areturn
     324: new           #76                 // class java/lang/StringBuilder
     327: dup
     328: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
     331: ldc           #239                // String set at
     333: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     336: iload         8
     338: invokevirtual #242                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     341: bipush        44
     343: invokevirtual #87                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     346: iload         10
     348: invokevirtual #242                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     351: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     354: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     357: swap
     358: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     361: aload         7
     363: new           #125                // class Position
     366: dup
     367: iload         10
     369: iload         8
     371: invokespecial #231                // Method Position."<init>":(II)V
     374: invokeinterface #246,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     379: pop
     380: iload         10
     382: iload         11
     384: if_icmpeq     393
     387: iinc          10, 1
     390: goto          294
     393: iload         8
     395: iload         9
     397: if_icmpeq     406
     400: iinc          8, 1
     403: goto          261
     406: aload_3
     407: new           #120                // class Ship
     410: dup
     411: aload         7
     413: invokespecial #249                // Method Ship."<init>":(Ljava/util/List;)V
     416: invokeinterface #252,  2          // InterfaceMethod java/util/List.addLast:(Ljava/lang/Object;)V
     421: aload_1
     422: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
     425: if_acmpne     442
     428: aload_0
     429: aconst_null
     430: aconst_null
     431: aload_3
     432: aconst_null
     433: bipush        11
     435: aconst_null
     436: invokestatic  #256                // Method GameState.copy$default:(LGameState;[[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)LGameState;
     439: goto          453
     442: aload_0
     443: aconst_null
     444: aconst_null
     445: aconst_null
     446: aload_3
     447: bipush        7
     449: aconst_null
     450: invokestatic  #256                // Method GameState.copy$default:(LGameState;[[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)LGameState;
     453: areturn

  public static final boolean isCellOccupied(GameState, Player, Position);
    Code:
       0: aload_0
       1: ldc           #66                 // String gameState
       3: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #74                 // String player
       9: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc_w         #264                // String position
      16: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      19: aload_1
      20: getstatic     #16                 // Field Player.PLAYER1:LPlayer;
      23: if_acmpne     33
      26: aload_0
      27: invokevirtual #99                 // Method GameState.getShips1:()Ljava/util/List;
      30: goto          37
      33: aload_0
      34: invokevirtual #102                // Method GameState.getShips2:()Ljava/util/List;
      37: astore_3
      38: aload_3
      39: checkcast     #104                // class java/lang/Iterable
      42: astore        4
      44: iconst_0
      45: istore        5
      47: aload         4
      49: instanceof    #184                // class java/util/Collection
      52: ifeq          72
      55: aload         4
      57: checkcast     #184                // class java/util/Collection
      60: invokeinterface #267,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      65: ifeq          72
      68: iconst_0
      69: goto          209
      72: aload         4
      74: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      79: astore        6
      81: aload         6
      83: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      88: ifeq          208
      91: aload         6
      93: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      98: astore        7
     100: aload         7
     102: checkcast     #120                // class Ship
     105: astore        8
     107: iconst_0
     108: istore        9
     110: aload         8
     112: invokevirtual #123                // Method Ship.getParts:()Ljava/util/List;
     115: checkcast     #104                // class java/lang/Iterable
     118: astore        10
     120: iconst_0
     121: istore        11
     123: aload         10
     125: instanceof    #184                // class java/util/Collection
     128: ifeq          148
     131: aload         10
     133: checkcast     #184                // class java/util/Collection
     136: invokeinterface #267,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     141: ifeq          148
     144: iconst_0
     145: goto          200
     148: aload         10
     150: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     155: astore        12
     157: aload         12
     159: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     164: ifeq          199
     167: aload         12
     169: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     174: astore        13
     176: aload         13
     178: checkcast     #125                // class Position
     181: astore        14
     183: iconst_0
     184: istore        15
     186: aload         14
     188: aload_2
     189: invokestatic  #271                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     192: ifeq          157
     195: iconst_1
     196: goto          200
     199: iconst_0
     200: nop
     201: ifeq          81
     204: iconst_1
     205: goto          209
     208: iconst_0
     209: ireturn

  public static final kotlin.Pair<Position, Position> convertPair(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #279                // String input
       4: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #76                 // class java/lang/StringBuilder
      10: dup
      11: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
      14: ldc_w         #281                // String in convertPair
      17: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: aload_0
      21: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      30: swap
      31: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      34: new           #204                // class kotlin/Pair
      37: dup
      38: aload_0
      39: iconst_0
      40: iconst_2
      41: invokevirtual #285                // Method java/lang/String.substring:(II)Ljava/lang/String;
      44: dup
      45: ldc_w         #287                // String substring(...)
      48: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      51: invokestatic  #291                // Method convert:(Ljava/lang/String;)LPosition;
      54: aload_0
      55: iconst_2
      56: iconst_4
      57: invokevirtual #285                // Method java/lang/String.substring:(II)Ljava/lang/String;
      60: dup
      61: ldc_w         #287                // String substring(...)
      64: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      67: invokestatic  #291                // Method convert:(Ljava/lang/String;)LPosition;
      70: invokespecial #217                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      73: areturn

  public static final Position convert(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #279                // String input
       4: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #76                 // class java/lang/StringBuilder
      10: dup
      11: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
      14: ldc_w         #293                // String in convert
      17: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: aload_0
      21: invokevirtual #84                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      30: swap
      31: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      34: aload_0
      35: iconst_0
      36: invokevirtual #297                // Method java/lang/String.charAt:(I)C
      39: istore_1
      40: aload_0
      41: iconst_1
      42: invokevirtual #297                // Method java/lang/String.charAt:(I)C
      45: istore_2
      46: iload_1
      47: bipush        97
      49: isub
      50: istore_3
      51: iload_2
      52: invokestatic  #300                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      55: invokestatic  #304                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      58: istore        4
      60: new           #125                // class Position
      63: dup
      64: iload_3
      65: iload         4
      67: invokespecial #231                // Method Position."<init>":(II)V
      70: areturn

  public static final void check();
    Code:
       0: invokestatic  #163                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
       3: getstatic     #169                // Field java/util/Locale.ROOT:Ljava/util/Locale;
       6: invokevirtual #173                // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
       9: dup
      10: ldc           #175                // String toLowerCase(...)
      12: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      15: astore_0
      16: getstatic     #311                // Field Function.CHECK:LFunction;
      19: aload_0
      20: invokestatic  #198                // Method inputIsValid:(LFunction;Ljava/lang/String;)Z
      23: ifeq          26
      26: return

  public static final boolean inputIsValid(Function, java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #314                // String function
       4: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #279                // String input
      11: invokestatic  #72                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      17: aload_0
      18: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      21: aload_0
      22: getstatic     #320                // Field MainKt$WhenMappings.$EnumSwitchMapping$0:[I
      25: swap
      26: invokevirtual #323                // Method Function.ordinal:()I
      29: iaload
      30: tableswitch   { // 1 to 2
                     1: 52
                     2: 134
               default: 338
          }
      52: aload_1
      53: invokevirtual #326                // Method java/lang/String.length:()I
      56: iconst_2
      57: if_icmpne     122
      60: aload_1
      61: iconst_0
      62: invokevirtual #297                // Method java/lang/String.charAt:(I)C
      65: istore_2
      66: bipush        97
      68: iload_2
      69: if_icmpgt     86
      72: iload_2
      73: bipush        107
      75: if_icmpge     82
      78: iconst_1
      79: goto          87
      82: iconst_0
      83: goto          87
      86: iconst_0
      87: ifeq          122
      90: aload_1
      91: iconst_1
      92: invokevirtual #297                // Method java/lang/String.charAt:(I)C
      95: istore_2
      96: bipush        48
      98: iload_2
      99: if_icmpgt     116
     102: iload_2
     103: bipush        58
     105: if_icmpge     112
     108: iconst_1
     109: goto          117
     112: iconst_0
     113: goto          117
     116: iconst_0
     117: ifeq          122
     120: iconst_1
     121: ireturn
     122: ldc_w         #328                // String Enter the cell index in format \"letternumber\", for example \"a0a3\"
     125: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     128: swap
     129: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     132: iconst_0
     133: ireturn
     134: aload_1
     135: invokevirtual #326                // Method java/lang/String.length:()I
     138: iconst_4
     139: if_icmpne     326
     142: aload_1
     143: iconst_0
     144: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     147: istore_2
     148: bipush        97
     150: iload_2
     151: if_icmpgt     168
     154: iload_2
     155: bipush        107
     157: if_icmpge     164
     160: iconst_1
     161: goto          169
     164: iconst_0
     165: goto          169
     168: iconst_0
     169: ifeq          326
     172: aload_1
     173: iconst_1
     174: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     177: istore_2
     178: bipush        48
     180: iload_2
     181: if_icmpgt     198
     184: iload_2
     185: bipush        58
     187: if_icmpge     194
     190: iconst_1
     191: goto          199
     194: iconst_0
     195: goto          199
     198: iconst_0
     199: ifeq          326
     202: aload_1
     203: iconst_2
     204: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     207: istore_2
     208: bipush        97
     210: iload_2
     211: if_icmpgt     228
     214: iload_2
     215: bipush        107
     217: if_icmpge     224
     220: iconst_1
     221: goto          229
     224: iconst_0
     225: goto          229
     228: iconst_0
     229: ifeq          326
     232: aload_1
     233: iconst_3
     234: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     237: istore_2
     238: bipush        48
     240: iload_2
     241: if_icmpgt     258
     244: iload_2
     245: bipush        58
     247: if_icmpge     254
     250: iconst_1
     251: goto          259
     254: iconst_0
     255: goto          259
     258: iconst_0
     259: ifeq          326
     262: aload_1
     263: iconst_0
     264: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     267: aload_1
     268: iconst_2
     269: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     272: if_icmpeq     288
     275: aload_1
     276: iconst_1
     277: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     280: aload_1
     281: iconst_3
     282: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     285: if_icmpne     326
     288: aload_1
     289: iconst_0
     290: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     293: aload_1
     294: iconst_2
     295: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     298: isub
     299: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     302: iconst_3
     303: if_icmpgt     326
     306: aload_1
     307: iconst_1
     308: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     311: aload_1
     312: iconst_3
     313: invokevirtual #297                // Method java/lang/String.charAt:(I)C
     316: isub
     317: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     320: iconst_3
     321: if_icmpgt     326
     324: iconst_1
     325: ireturn
     326: ldc_w         #336                // String Enter the cell indexes in format \"letternumberletternumber\" for placing ship, for example \"a0b0\"
     329: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     332: swap
     333: invokevirtual #182                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     336: iconst_0
     337: ireturn
     338: new           #338                // class kotlin/NoWhenBranchMatchedException
     341: dup
     342: invokespecial #339                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     345: athrow

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


//  Special Permutation
//  https://codeforces.com/contest/1347/problem/E

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

fun main() {
    val lines = readInt()
    for (line in 1..lines) {
        val number = readInt()
        if (number < 4) {
            println("-1")
        } else {
            println(getPermutation(number).joinToString(" "))
        }
    }
}

fun getPermutation(number: Int): List<Int> {
    val permutations = mutableSetOf<Int>()
    val numbers = (1..number).map { it } as MutableList

    val evens = numbers.filter { it % 2 == 0}

    permutations.addAll(evens)

    val odds = numbers.filter { it % 2 != 0}.reversed()

    permutations.add(evens.last()-3)

    permutations.addAll(odds)

    return permutations.toList()
}

Compiled from "practice4e.kt"
public final class Practice4eKt {
  private static final java.lang.String readLn();
    Code:
       0: invokestatic  #11                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: dup
       4: invokestatic  #17                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: areturn

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

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

  public static final void main();
    Code:
       0: invokestatic  #103                // Method readInt:()I
       3: istore_0
       4: iconst_1
       5: istore_1
       6: iload_1
       7: iload_0
       8: if_icmpgt     73
      11: invokestatic  #103                // Method readInt:()I
      14: istore_2
      15: iload_2
      16: iconst_4
      17: if_icmpge     32
      20: ldc           #105                // String -1
      22: getstatic     #111                // Field java/lang/System.out:Ljava/io/PrintStream;
      25: swap
      26: invokevirtual #116                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      29: goto          62
      32: iload_2
      33: invokestatic  #120                // Method getPermutation:(I)Ljava/util/List;
      36: checkcast     #48                 // class java/lang/Iterable
      39: ldc           #36                 // String
      41: checkcast     #32                 // class java/lang/CharSequence
      44: aconst_null
      45: aconst_null
      46: iconst_0
      47: aconst_null
      48: aconst_null
      49: bipush        62
      51: aconst_null
      52: invokestatic  #124                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      55: getstatic     #111                // Field java/lang/System.out:Ljava/io/PrintStream;
      58: swap
      59: invokevirtual #116                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      62: iload_1
      63: iload_0
      64: if_icmpeq     73
      67: iinc          1, 1
      70: goto          11
      73: return

  public static final java.util.List<java.lang.Integer> getPermutation(int);
    Code:
       0: new           #131                // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #133                // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #135                // class java/util/Set
      10: astore_1
      11: new           #137                // class kotlin/ranges/IntRange
      14: dup
      15: iconst_1
      16: iload_0
      17: invokespecial #140                // Method kotlin/ranges/IntRange."<init>":(II)V
      20: checkcast     #48                 // class java/lang/Iterable
      23: astore        4
      25: iconst_0
      26: istore        5
      28: aload         4
      30: astore        6
      32: new           #50                 // class java/util/ArrayList
      35: dup
      36: aload         4
      38: bipush        10
      40: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #62                 // class java/util/Collection
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload         6
      56: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        9
      63: aload         9
      65: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          111
      73: aload         9
      75: checkcast     #142                // class kotlin/collections/IntIterator
      78: invokevirtual #145                // Method kotlin/collections/IntIterator.nextInt:()I
      81: istore        10
      83: aload         7
      85: iload         10
      87: istore        11
      89: astore        14
      91: iconst_0
      92: istore        12
      94: iload         11
      96: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      99: aload         14
     101: swap
     102: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          63
     111: aload         7
     113: checkcast     #86                 // class java/util/List
     116: nop
     117: invokestatic  #151                // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;
     120: astore_2
     121: aload_2
     122: checkcast     #48                 // class java/lang/Iterable
     125: astore        4
     127: iconst_0
     128: istore        5
     130: aload         4
     132: astore        6
     134: new           #50                 // class java/util/ArrayList
     137: dup
     138: invokespecial #152                // Method java/util/ArrayList."<init>":()V
     141: checkcast     #62                 // class java/util/Collection
     144: astore        7
     146: iconst_0
     147: istore        8
     149: aload         6
     151: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     156: astore        9
     158: aload         9
     160: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     165: ifeq          218
     168: aload         9
     170: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     175: astore        10
     177: aload         10
     179: checkcast     #154                // class java/lang/Number
     182: invokevirtual #157                // Method java/lang/Number.intValue:()I
     185: istore        11
     187: iconst_0
     188: istore        12
     190: iload         11
     192: iconst_2
     193: irem
     194: ifne          201
     197: iconst_1
     198: goto          202
     201: iconst_0
     202: ifeq          158
     205: aload         7
     207: aload         10
     209: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     214: pop
     215: goto          158
     218: aload         7
     220: checkcast     #86                 // class java/util/List
     223: nop
     224: astore_3
     225: aload_1
     226: aload_3
     227: checkcast     #62                 // class java/util/Collection
     230: invokeinterface #161,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     235: pop
     236: aload_2
     237: checkcast     #48                 // class java/lang/Iterable
     240: astore        5
     242: iconst_0
     243: istore        6
     245: aload         5
     247: astore        7
     249: new           #50                 // class java/util/ArrayList
     252: dup
     253: invokespecial #152                // Method java/util/ArrayList."<init>":()V
     256: checkcast     #62                 // class java/util/Collection
     259: astore        8
     261: iconst_0
     262: istore        9
     264: aload         7
     266: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     271: astore        10
     273: aload         10
     275: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     280: ifeq          333
     283: aload         10
     285: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     290: astore        11
     292: aload         11
     294: checkcast     #154                // class java/lang/Number
     297: invokevirtual #157                // Method java/lang/Number.intValue:()I
     300: istore        12
     302: iconst_0
     303: istore        13
     305: iload         12
     307: iconst_2
     308: irem
     309: ifeq          316
     312: iconst_1
     313: goto          317
     316: iconst_0
     317: ifeq          273
     320: aload         8
     322: aload         11
     324: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     329: pop
     330: goto          273
     333: aload         8
     335: checkcast     #86                 // class java/util/List
     338: nop
     339: checkcast     #48                 // class java/lang/Iterable
     342: invokestatic  #165                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     345: astore        4
     347: aload_1
     348: aload_3
     349: invokestatic  #169                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     352: checkcast     #154                // class java/lang/Number
     355: invokevirtual #157                // Method java/lang/Number.intValue:()I
     358: iconst_3
     359: isub
     360: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     363: invokeinterface #170,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     368: pop
     369: aload_1
     370: aload         4
     372: checkcast     #62                 // class java/util/Collection
     375: invokeinterface #161,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     380: pop
     381: aload_1
     382: checkcast     #48                 // class java/lang/Iterable
     385: invokestatic  #173                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     388: areturn

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