#include #include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } struct IOST { IOST() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } } IOST; int timer() { static auto st = chrono::system_clock::now(); auto en = chrono::system_clock::now(); return chrono::duration_cast(en - st).count(); } void solve() { timer(); int n; cin >> n; vector> a(n, vector(n)); rep(i, 0, n) rep(j, 0, n) cin >> a[i][j]; auto print_p = [&](const vector& p) { rep(i, 0, n) { rep(j, 0, n) cout << p[i * n + j] << " "; cout << "\n"; } }; auto check_p = [&](vector p) { int ad = 0; rep(i, 0, n) rep(j, 0, n) { if (p[i * n + j] == 0) { ad = (i + j) & 1; } } rep(i, 0, n * n) { if (p[i] != i) { swap(p[i], p[p[i]]); ad = (ad + 1) & 1; } } return ad; }; vector p(n * n); iota(p.begin(), p.end(), 0); map> mp; do { if (check_p(p)) continue; ll tmp = 0; rep(i, 0, n) { rep(j, 0, n) tmp += a[i][j] * p[i * n + j]; } if (mp.count(tmp)) { cout << "Yes\n"; print_p(p); print_p(mp[tmp]); return; } mp[tmp] = p; if (timer() > 3500) break; } while (next_permutation(p.begin(), p.end())); cout << "No\n"; } int main() { int t = 1; // cin >> t; rep(i, 0, t) solve(); }