#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define is_mul_overflow(a, b) \ ((b != 0) && (a > LLONG_MAX / b || a < LLONG_MIN / b)) typedef pair pli; typedef pair pil; typedef pair pll; typedef pair pii; typedef pair pdd; typedef pair piii; typedef pair pil; typedef pair plii; typedef pair pdi; typedef long long ll; typedef unsigned long long ull; typedef pair puu; typedef long double ld; const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f, MID = 333; const long double EPS = 1e-8; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; // int dx[8] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[8] = {1, 2, 2, 1, -1, -2, -2, -1}; int n, m, cnt; int w[N]; vector num; ll res; ll lowbit(ll x) { return x & -x; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } inline double rand(double l, double r) { return (double)rand() / RAND_MAX * (r - l) + l; } inline ll qmi(ll a, ll b, ll c) { ll res = 1; while (b) { if (b & 1) res = res * a % c; a = a * a % c; b >>= 1; } return res; } inline ll qmi(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } inline double qmi(double a, ll b) { double res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } // inline ll C(ll a, ll b) { if (a < b) return 0; if (b > a - b) b = a - b; ll res = 1; for (ll i = 1, j = a; i <= b; i++, j--) { res = res * (j % MOD) % MOD; res = res * qmi(i, MOD - 2, MOD) % MOD; } return res; } inline ll C(ll a, ll b, int* c) { if (a < b) return 0; ll res = 1; for (ll j = a, i = 1; i < b + 1; i++, j--) res *= j; for (ll j = a, i = 1; i < b + 1; i++, j--) res /= i; return res; } inline int find_(int x) { return lower_bound(num.begin(), num.end(), x) - num.begin(); } int a[1086][1086]; int e[N], ne[N], h[N], idx; inline void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } bool st[N]; void dfs(int r) { for (int i = h[r]; ~i; i = ne[i]) { if (st[i]) continue; st[i ^ 1] = st[i] = 1; a[r][e[i]] = 1, a[e[i]][r] = -1; dfs(e[i]); } } void check() { for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; j < n; j++) { sum += a[i][j]; assert(a[i][j] == -a[j][i]); if (lowbit(i ^ j) == (i ^ j) && (i ^ j)) assert(a[i][j]); else assert(a[i][j] == 0); } assert(sum == 0); } } int main() { cin >> n; memset(h, -1, sizeof(int) * 2048); if (n == 1) { puts("No"); return 0; } int t = n; n = 1 << n; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { if (lowbit(i ^ j) == (i ^ j)) a[i][j] = a[j][i] = 3; if (t & 1 && (i ^ j) == (1 << (t - 1))) continue; if (lowbit(i ^ j) == (i ^ j)) add(i, j), add(j, i); } puts("Yes"); a[e[1]][e[0]] = 1, a[e[0]][e[1]] = -1, st[1] = st[0] = 1; dfs(e[0]); if (t & 1) { for (int i = 0; i < n / 2; i++) { int ft = i; bool flag = 0; for (int j = 0; j <= n / 2; j++) flag |= abs(a[i][j]) == 2, ft = abs(a[i][j]) == 2 ? j : ft; for (int j = i + 1; j < n; j++) { if (a[i][j] == 3) { // assert(ft != i); if (flag) a[i][j] = a[i][ft] == 2 ? -1 : 1, a[n - 1 - i][n - 1 - j] = -a[i][j]; else a[i][j] = -a[i][ft], a[n - 1 - i][n - 1 - j] = -a[i][j], a[i][ft] = a[i][ft] == 1 ? 2 : -2, a[ft][i] = -a[i][ft], a[n - 1 - ft][n - 1 - i] = -a[i][ft], a[n - 1 - i][n - 1 - ft] = -a[i][ft]; break; } ft = a[i][ft] ? ft : j; } } for (int i = 0; i < n / 2; i++) for (int j = 0; j < n / 2; j++) if (a[i][j]) a[n - 1 - i][n - 1 - j] = -a[i][j]; } // check(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) printf("%d ", a[i][j]); puts(""); } }