import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { new Main().run(); } boolean[][] win; long[] cnt = new long[16]; void run() { Scanner sc = new Scanner(); win = new boolean[16][16]; for (int i = 0; i < win.length; ++i) { for (int j = 0; j < win[i].length; ++j) { win[i][j] = (sc.nextInt() == 1); } } for (int i = 0; i < win.length; ++i) { for (int j = 0; j < win[i].length; ++j) { if (i > j) { win[i][j] = !win[j][i]; } } } PrintWriter pw = new PrintWriter(System.out); long[][] dp = new long[16][1 << 16]; ArrayList[] list = new ArrayList[16]; for (int i = 0; i < 5; ++i) { list[i] = new ArrayList(); } boolean[] add = new boolean[1 << 16]; for (int i = 0; i < 16; ++i) { dp[i][1 << i] = 1; list[0].add(1 << i); add[1 << i] = true; } for (int i = 0; i < 4; ++i) { for (int j = 0; j < list[i].size(); ++j) { for (int k = 0; k < list[i].size(); ++k) { int s1 = list[i].get(j); int s2 = list[i].get(k); if ((s1 & s2) > 0) { continue; } for (int a = 0; a < 16; ++a) { if (((1 << a) & s1) == 0) continue; for (int b = 0; b < 16; ++b) { if (((1 << b) & s2) == 0) continue; int whowin = win[a][b] ? a : b; dp[whowin][s1 | s2] = dp[whowin][s1 | s2] + dp[a][s1] * dp[b][s2]; if (!add[s1 | s2]) { list[i + 1].add(s1 | s2); add[s1 | s2] = true; } } } } } } long sum = 0; for (int i = 0; i < 16; ++i) { System.out.println(dp[i][(1 << 16) - 1]); sum += dp[i][(1 << 16) - 1]; } pw.close(); } static long gcd(long a, long b) { if (a > b) return gcd(b, a); if (a == 0) return b; return gcd(b % a, a); } static class Scanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int) nextLong(); } } public static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }