#include #define rep(i,n) for (int i = 0; i < int(n); ++i) #define repp(i,n,m) for (int i = m; i < int(n); ++i) using namespace std; using ll = long long; int n; vector> win(16,vector(16,0)); vector solve(vector join){ int m = join.size(); if (m == 16){ vector ans(16,0); rep(a,9) repp(b,10,a+1) repp(c,11,b+1) repp(d,12,c+1) repp(e,13,d+1) repp(f,14,e+1) repp(g,15,f+1){ vector x = {a,b,c,d,e,f,g,15}; vector _cnt(16,0); rep(i,8) _cnt[x[i]]++; vector y; rep(i,16) if (_cnt[i] == 0) y.emplace_back(i); vector p = solve(x); vector q = solve(y); rep(i,8) rep(j,8){ if (win[x[i]][y[j]] == 1) ans[x[i]] += p[i] * q[j] * 2; else ans[y[j]] += p[i] * q[j] * 2; } } return ans; } if (m == 8){ vector ans(8,0); rep(a,5) repp(b,6,a+1) repp(c,7,b+1){ vector inda = {a,b,c,7}; vector indb; vector _cnt(8,0); rep(i,4) _cnt[inda[i]]++; rep(i,8) if (_cnt[i] == 0) indb.emplace_back(i); vector x(4), y(4); rep(i,4) x[i] = join[inda[i]]; rep(i,4) y[i] = join[indb[i]]; vector p = solve(x); vector q = solve(y); rep(i,4) rep(j,4){ if (win[x[i]][y[j]] == 1) ans[inda[i]] += p[i] * q[j] * 2; else ans[indb[j]] += p[i] * q[j] * 2; } } return ans; } if (m == 4){ vector ans(4,0); rep(a,3){ vector inda = {a,3}; vector indb; vector _cnt(4,0); rep(i,2) _cnt[inda[i]]++; rep(i,4) if (_cnt[i] == 0) indb.emplace_back(i); vector x(2), y(2); rep(i,2) x[i] = join[inda[i]]; rep(i,2) y[i] = join[indb[i]]; vector p(2,0); vector q(2,0); if (win[x[0]][x[1]] == 1) p[0] = 2; else p[1] = 2; if (win[y[0]][y[1]] == 1) q[0] = 2; else q[1] = 2; rep(i,2) rep(j,2){ if (win[x[i]][y[j]] == 1) ans[inda[i]] += p[i] * q[j] * 2; else ans[indb[j]] += p[i] * q[j] * 2; } } return ans; } if (m == 2){ vector ans(2,0); if (win[0][1] == 1) ans[0] = 2; else ans[1] = 2; return ans; } } int main(){ cin >> n; rep(i,n) rep(j,n) cin >> win[i][j]; vector c(n); rep(i,n) c[i] = i; vector ans = solve(c); rep(i,n) cout << ans[i] << endl; }