N = gets.to_i arr = [*1..N] puts (0...N).map { |x| arr.rotate(x).join(' ') }