#include using namespace std; using u32 = uint32_t; using ll = long long; int main(){ int N; cin >> N; vector S(N, vector(N)); for(auto& s : S) for(int& i : s) cin >> i; // dp[winner][bit] = #arrangement vector dp(N, vector(1 << N)); vector> A; for(int i = 0; i < N; i++){ dp[i][1 << i] = 1; A.emplace_back(i, 1 << i); } for(int i = 2; i < N; i <<= 1){ vector> B; for(int i = 0; i < A.size(); i++) for(int j = i + 1; j < A.size(); j++){ auto [a, bit1] = A[i]; auto [b, bit2] = A[j]; if(bit1 & bit2) continue; auto add = [&](int a, u32 b, ll x){ if(dp[a][b] == 0) B.emplace_back(a, b); dp[a][b] += x; }; add(S[a][b] ? a : b, bit1 | bit2, dp[a][bit1] * dp[b][bit2] * 2); } A = move(B); } const int mask = (1 << N) - 1; for(int bit = 0; bit < 1 << (N - 1); bit++) if(__builtin_popcount(bit) == N / 2){ for(int i = 0; i < N; i++) if(bit & 1 << i){ for(int j = 0; j < N; j++) if(~bit & 1 << j){ dp[S[i][j] ? i : j].back() += dp[i][bit] * dp[j][~bit & mask] * 2; } } } for(int i = 0; i < N; i++) cout << dp[i].back() << '\n'; }