import sys from itertools import permutations sys.setrecursionlimit(10 ** 7) def get_list(ty=int): return list(map(ty, input().split())) def get_int(): return int(input()) def get_str(): return input() N = get_int() S = [] for n in range(N): S.append(get_list()) cache = {} def rec(p): if p in cache: return cache[p] if len(p) == 2: cache[p] = p[0] if S[p[0]][p[1]] else p[1] return cache[p] idx = [] for i in range(0, 1 + len(p) // 2, len(p) // 2): idx.append(rec(p[i:(i + len(p) // 2)])) cache[p] = idx[0] if S[idx[0]][idx[1]] else idx[1] return cache[p] cnt = [0] * N for p in permutations(range(N)): cnt[rec(p)] += 1 for n in range(N): print(cnt[n])