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

fun main(args: Array<String>) {
    val rng = Random(args.contentHashCode().toLong())
    val n = args[0].toInt()
    val swaps = args[1].toInt()
    val a = rng.nextPermutation(n)
    val b = rng.makeSwaps(a, swaps)
    println(n)
    println(a.map { it + 1 }.joinToString(" "))
    println(b.map { it + 1 }.joinToString(" "))
}

private fun Random.makeSwaps(a: Array<Int>, swaps: Int): Array<Int> {
    val b = a.clone()
    if (a.size > 1) {
        repeat(swaps) {
            val pos = nextInt(b.size - 1)
            if (abs(b[pos] - b[pos + 1]) > 1) {
                b.swap(pos, pos + 1)
            }
        }
    }
    return b
}

private fun <T> Array<T>.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}

private fun Random.nextPermutation(n: Int): Array<Int> {
    val result = Array(n) { 0 }
    for (i in 1..result.lastIndex) {
        val pos = nextInt(i + 1)
        result[i] = result[pos]
        result[pos] = i
    }
    return result
}