#include using namespace std; using int64 = long long; int S[16][16]; int pop[1 << 16]; int64 dp[1 << 16][16]; int64 rec(int win, int bit) { if(~dp[bit][win]) return dp[bit][win]; int64 ret = 0, dep = pop[bit] >> 1; if(dep == 0) return 1; for(int i = bit; i > 0; i = (i - 1) & bit) { int other = i ^bit; if((i >> win) & 1) { if(pop[i] == dep && pop[other] == dep) { for(int j = 0; j < 16; j++) { if((other >> j) & 1) { if(S[win][j] == 1) { ret += rec(win, i) * rec(j, other) * 2; } } } } } } return dp[bit][win] = ret; } int main() { for(int i = 0; i < 16; i++) { for(int j = 0; j < 16; j++) { cin >> S[i][j]; } } for(int i = 0; i < 16; i++) { for(int j = 0; j < 16; j++) { if(S[i][j] == 0) { S[i][j] = -S[j][i]; } } } for(int i = 0; i < 1 << 16; i++) { pop[i] = __builtin_popcount(i); } memset(dp, -1, sizeof(dp)); for(int i = 0; i < 16; i++) { cout << rec(i, (1 << 16) - 1) << endl; } }