// solved by Dispersion #include using namespace std; typedef long long ll; typedef long double ld; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } vector> bai(vector> &A, bool mul) { ll n = A.size(); vector> ret(2 * n, vector(2 * n, 0)); // ret = {{A, I}, {I, A}} 的な for (int i = 0; i < n ; ++i) { for (int j = 0; j < n; ++j) { ret[i][j] = A[i][j]; ret[n+i][n+j] = A[i][j] * (-1); } } for (int i = 0; i < n; ++i) { ret[i][n+i] = (i % 2 == 0 ? 1 : -1); if (mul && i < n/2) {ret[i][n+i] *= -1;} ret[n+i][i] = -ret[i][n+i]; } return ret; } bool judge(vector> &A) { ll M = A.size(); // check for (int i = 0; i < M; ++i) { ll row_sum = 0; for (int j = 0; j < M; ++j) { if (__builtin_popcount(i^j) == 1 ^ A[i][j] != 0) { return false; } if (A[i][j] + A[j][i] != 0) { return false; } row_sum += A[i][j]; } if (row_sum != 0) { cout << i << " " << row_sum << endl; return false; } } return true; } int main() { ll N; cin >> N; ll M = (1LL<> ans; if (N % 2 == 0) { vector> m2 = { {0, 1, -1, 0}, {-1, 0, 0, 1}, {1, 0, 0, -1}, {0, -1, 1, 0} }; ans = m2; ll t = (N - 2) / 2; while (t--) { ans = bai(ans, false); ans = bai(ans, true); } } else { vector> m3 = { {0, 1, 1, 0, -2, 0, 0, 0}, {-1, 0, 0, -1, 0, 2, 0, 0}, {-1, 0, 0, -1, 0, 0, 2, 0}, {0, 1, 1, 0, 0, 0, 0, -2}, {2, 0, 0, 0, 0, -1, -1, 0}, {0, -2, 0, 0, 1, 0, 0, 1}, {0, 0, -2, 0, 1, 0, 0, 1}, {0, 0, 0, 2, 0, -1, -1, 0} }; ans = m3; ll t = (N - 3) / 2; while (t--) { ans = bai(ans, false); ans = bai(ans, true); } } // output cout << "Yes" << endl; for (int i = 0; i < M; ++i) { for (int j = 0; j < M; ++j) { cout << ans[i][j] << " "; } cout << endl; } // judge bool flg = judge(ans); return 0; }