import java.util.*

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

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
}