public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int f = 0;
		d: do {
			int s = scan.nextInt();
			if (s == 0)
				break d;
			int[][] m = new int[s][s];
			for (int i = 0; i < m.length; i++)
				for (int j = 0; j < m.length; j++)
					m[i][j] = scan.nextInt();
			sb.append(((f++ != 0) ? "\n" : "") + v(m));
		} while (scan.hasNext());
		System.out.println(sb);
	}