import kotlin.random.Random
import kotlin.random.nextInt

const val MAX = 100_000
const val MAX_T = 1_000

fun main(args: Array<String>) {
    val range = args[0].toIntRange()
    val rng = Random(args.contentHashCode())
    var sum = 0
    val tests = mutableListOf<String>()
    while (tests.size < MAX_T * 3) {
        val n = rng.nextInt(range)
        if (sum + n > MAX) {
            break
        }
        sum += n
        val start = rng.randomState(n)
        val finish = rng.randomState(n)
        tests.add("$n")
        tests.add(start.joinToString(" "))
        tests.add(finish.joinToString(" "))
    }
    println(tests.size / 3)
    for (line in tests) {
        println(line)
    }
}

fun Random.randomState(n: Int): IntArray = IntArray(n) { nextInt(1..3) }

fun String.toIntRange(): IntRange {
    val (from, to) = this.split("..").map { it.toInt() }
    return from..to
}


