use std::io::Read; fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } fn get() -> T { get_word().parse().ok().unwrap() } fn main() { let n: usize = get(); if n == 1 { println!("-1"); return; } let mut cur = 2; let mut dat = vec![ vec![7, 14, 0, 8], vec![4, 12, 2, 11], vec![15, 9, 6, 1], vec![13, 10, 5, 3], ]; while cur < n { let mut new = vec![vec![0; 1 << (cur + 1)]; 1 << (cur + 1)]; for x in 0..1 << (cur + 1) { for y in 0..1 << (cur + 1) { let added = (x >> cur) + 2 * (y >> cur); new[x][y] = added << (2 * cur) | dat[x & ((1 << cur) - 1)][y & ((1 << cur) - 1)]; } } dat = new; cur += 1; } for i in 0..1 << n { for j in 0..1 << n { print!("{}{}", dat[i][j], if j + 1 == 1 << n { "\n" } else { " " }); } } }