#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void slv(); int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); slv(); return 0; } using ll = long long; using ld = long double; using pii = pair; using pll = pair; templateusing vc = vector; using vi = vector; using vvi = vector>; using vl = vector; using vvl = vector>; using vs = vector; const int INF = 1000000007; constexpr double PI = 3.14159265358979323846; constexpr char _ = ' '; #define endl '\n' #define rep(i,n) for(int i=0;i<(int)n;i++) #define sz(v) (int)v.size() #define bg begin() #define ed end() #define all(v) v.begin(),v.end() #define F first #define S second #define mp make_pair #define pb emplace_back #define bs binary_search #define lb lower_bound #define ub upper_bound #define tostr to_string void yesno(bool ans) { cout << (ans ? "yes" : "no") << endl; } void YesNo(bool ans) { cout << (ans ? "Yes" : "No") << endl; } void YESNO(bool ans) { cout << (ans ? "YES" : "NO") << endl; } templatevoid i(T& v) { rep(i, sz(v))cin >> v[i]; } templatevoid i(T& A, U& B) { if (sz(A) - sz(B))return; rep(i, sz(A))cin >> A[i] >> B[i]; } templatevoid i(T& A, U& B, V& C) { if (sz(A) - sz(B) || sz(A) - sz(C))return; rep(i, sz(A))cin >> A[i] >> B[i] >> C[i]; } templatevoid o(T& v) { rep(i, sz(v))cout << v[i] << (i != sz(v) - 1 ? _ : '\n'); } templatevoid oendl(T& v) { rep(i, sz(v))cout << v[i] << endl; } templatevoid oendl(T& A, U& B) { if (sz(A) - sz(B))return; rep(i, sz(A))cout << A[i] << _ << B[i] << endl; } templatevoid oendl(T& A, U& B, V& C) { if (sz(A) - sz(B) || sz(A) - sz(C))return; rep(i, sz(A))cout << A[i] << _ << B[i] << _ << C[i] << endl; } templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; }return 0; } templatebool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; }return 0; } templatevoid dedupe(T& v) { v.erase(unique(all(v)), v.end()); } templateauto cmprs(T& v) { T vals = v, res(sz(v)); sort(all(vals)), dedupe(vals); rep(i, sz(v))res[i] = lb(all(vals), v[i]) - vals.begin(); return res; } constexpr int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }, dw[4] = { 1,0,-1,0 }, dh[4] = { 0,1,0,-1 }; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); } ll gcd(ll a, ll b, ll c) { return gcd(gcd(a, b), c); } templatebool isprime_Onv(T n) { if (n < 2)return false; for (T i = 2; i * i <= n; i++)if (n % i == 0) { return false; } return true; } auto Eratosthenes = [](int n) {vectorisprime(n + 1, true); if (n > 0)isprime[0] = false; if (n > 1)isprime[1] = false; for (int i = 2; i * i <= n; i++) { if (isprime[i])for (int j = i * i; j <= n; j += i) isprime[j] = false; } return isprime; }; templatevcalldiv(T n) { vcres; for (T i = 1; i * i <= n; i++)if (n % i == 0) { res.pb(i); if (i * i != n)res.pb(n / i); }sort(all(res)); return res; } ll pow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1)res *= x; x *= x, n >>= 1; }return res; } ll pow(ll x, ll n, ll M) { ll res = 1LL; while (n > 0) { if (n & 1)res = res * x % M; x = x * x % M; n >>= 1; }return res; } bool next_day(int& Y, int& M, int& D) { auto m_end = [](int y, int m, int d) {auto L = [](int y) {return y % 4 ? 0 : (y % 100 ? 1 : (y % 400 ? 0 : 1)); }; return ((d == 31) || (d == 30 && (m == 4 || m == 6 || m == 9 || m == 11)) || !(m - 2 || d - L(y) - 28)) ? 1 : 0; }; m_end(Y, M, D) ? (M == 12 ? (D = 1, M = 1, Y++) : (D = 1, M++)) : D++; return 1; } struct UnionFind { UnionFind(int N) { par.resize(N), siz.resize(N); rep(i, N)makeTree(i); } bool isSame(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x), y = root(y); if (x == y)return; siz[x] > siz[y] ? (par[y] = x, siz[x] += siz[y]) : (par[x] = y, siz[y] += siz[x]); } int treeSize(int x) { return siz[root(x)]; } private: vectorpar, siz; void makeTree(int x) { par[x] = x, siz[x] = 1; } int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); } }; templatestruct SegTree { SegTree(int _n, function_monoid, T _e) :monoid(_monoid), e(_e) { n = 1; while (n < _n)n *= 2; data.assign(2 * n - 1, e); } void update(int i, T x) { i += n - 1; data[i] = x; while (i > 0) { i = (i - 1) / 2; data[i] = monoid(data[2 * i + 1], data[2 * i + 2]); } } T query(int a, int b) { return query(a, b, 0, 0, n); } T operator[](int i) { return data[i]; } private: int n; vectordata; functionmonoid; T e; T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) { return e; } if (a <= l && r <= b) { return data[k]; } return monoid(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r)); } }; void slv() { int N; cin >> N; int t = 0; for (int i = 1; i < N; i *= 2, t++); vvi S(N, vi(N)); for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) cin >> S[i][j]; vl ans(N, 0LL); vectorA(N); rep(i, N)A[i] = i; do { vector>winner(t + 1); winner[0] = A; for (int i = 0; i < t; i++) { while (winner[i].size()) { int x = winner[i].front(); winner[i].erase(winner[i].begin()); int y = winner[i].front(); winner[i].erase(winner[i].begin()); winner[i + 1].push_back(S[x][y] ? x : y); } } ans[winner[t][0]]++; } while (next_permutation(all(A))); //for (auto& a : ans)a = pow(a, N - 1); oendl(ans); }