#include #include #include using namespace std; constexpr int fighters = 16; inline int to_bits(array const& bits) { int result = 0; for (int i = 0; i < fighters; i++) result |= bits[i] << i; return result; } array, fighters> dp; int main() { array, fighters> result; for (auto& row : result) for (auto& v : row) cin >> v; for (int i = 0; i < fighters; i++) for (int j = 0; j < i; j++) result[i][j] = -result[j][i]; for (auto& row : dp) for (auto& v : row) v = 0; for (int i = 0; i < fighters; i++) dp[i][1 << i] = 1; for (int i = 0; i <= 3; i++) { int high_digit = 1 << i; array a, b; for (int j = 0; j < fighters; j++) a[j] = b[j] = ((fighters - j - 1 < high_digit) ? 1 : 0); do { do { int n = to_bits(a), m = to_bits(b); // cout << n << ' ' << m << endl; if ((n & m) != 0) continue; for (int j = 0; j < fighters; j++) { for (int k = 0; k < fighters; k++) { if (j == k) continue; if (result[j][k] > 0) dp[j][n | m] += dp[j][n] * dp[k][m]; else dp[k][n | m] += dp[j][n] * dp[k][m]; } } } while (next_permutation(begin(a), end(a))); } while (next_permutation(begin(b), end(b))); } for (int i = 0; i < fighters; i++) cout << dp[i][(1 << 16) - 1] << endl; }