use std::collections::*; use std::io::Write; type Map = BTreeMap; type Set = BTreeSet; type Deque = VecDeque; fn main() { input! { n: usize, } if n == 1 { println!("No"); return; } let mut base = if n % 2 == 0 { vec![vec![0]] } else { let mut a = vec![vec![0; 8]; 8]; for &(x, y, v) in [(0, 1, 1), (0, 2, 1), (1, 3, -1), (2, 3, -1)].iter() { a[x][y] = v; a[x + 4][y + 4] = -v; } for i in 0usize..4 { if i.count_ones() == 1 { a[i][i + 4] = 2; } else { a[i][i + 4] = -2; } } for i in 0..8 { for j in (i + 1)..8 { a[j][i] = -a[i][j]; } } a }; while base.len() < (1 << n) { let len = base.len(); let mut next = vec![vec![0; 4 * len]; 4 * len]; for i in 0usize..4 { for j in 0..4 { let x = i * len; let y = j * len; if (i ^ j).count_ones() == 0 { for (next, base) in next[x..(x + len)].iter_mut().zip(base.iter()) { next[y..(y + len)].copy_from_slice(base); } } else if i > j { for p in x..(x + len) { for q in y..(y + len) { next[p][q] = -next[q][p]; } } } else if (i ^ j).count_ones() == 1 { let v = if (i, j) == (0, 1) || (i, j) == (1, 3) { -1 } else { 1 }; for k in 0..len { next[x + k][y + k] = v; } } } } base = next; } println!("Yes"); for b in base.iter() { use util::*; println!("{}", b.iter().join(" ")); } for (i, b) in base.iter().enumerate() { for (j, b) in b.iter().enumerate() { if (i ^ j).count_ones() == 1 { assert!(*b != 0); } else { assert!(*b == 0); } } } } // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- mod util { pub trait Join { fn join(self, sep: &str) -> String; } impl Join for I where I: Iterator, T: std::fmt::Display, { fn join(self, sep: &str) -> String { let mut s = String::new(); use std::fmt::*; for (i, v) in self.enumerate() { if i > 0 { write!(&mut s, "{}", sep).ok(); } write!(&mut s, "{}", v).ok(); } s } } }