import scala.collection.mutable import scala.collection.mutable.ArrayBuffer import scala.io.StdIn.* import scala.util.chaining.* import scala.math.* import scala.util._ @main def main = val n = readLine.toInt val result = ArrayBuffer[List[Int]]() result.addOne((n until 2 * n).toList.reverse) result.addOne((n until 2 * n).toList.reverse) for i <- 0 until n - 1 do var list = List(n - 1) for j <- 0 until n do if i != j then list ::= n + j result.addOne(list) for i <- 1 to n - 2 do var list = Nil: List[Int] for j <- n - 1 - i until n - 1 do list ::= j for j <- 2 * n - (n - i) until 2 * n do list ::= j result.addOne(list) println(result.size) println(result.map(_.mkString(" ")).mkString("\n"))