import sys from itertools import combinations def main(): N = int(sys.stdin.readline()) S = [] for _ in range(N): row = list(map(int, sys.stdin.readline().split())) S.append(row) participants = list(range(N)) powers = [] current = 1 while current <= N: powers.append(current) current *= 2 dp = {} for m in powers: for subset in combinations(participants, m): bitmask = 0 for i in subset: bitmask |= 1 << i if m == 1: k = subset[0] dp[bitmask] = {k: 1} else: m_half = m // 2 all_splits = list(combinations(subset, m_half)) total = {} for a_group in all_splits: b_group = tuple(x for x in subset if x not in a_group) a_bitmask = 0 for x in a_group: a_bitmask |= 1 << x b_bitmask = 0 for x in b_group: b_bitmask |= 1 << x if a_bitmask not in dp or b_bitmask not in dp: continue a_dp = dp[a_bitmask] b_dp = dp[b_bitmask] for a in a_group: if a not in a_dp: continue for b in b_group: if b not in b_dp: continue count_a = a_dp[a] count_b = b_dp[b] if count_a == 0 or count_b == 0: continue if S[a][b] == 1: winner = a else: winner = b if winner not in total: total[winner] = 0 total[winner] += count_a * count_b dp[bitmask] = total full_bitmask = (1 << N) - 1 result = dp.get(full_bitmask, {}) for k in range(N): print(result.get(k, 0)) if __name__ == "__main__": main()