public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		int nCase = 1;
		while ((line = in.readLine()) != null && line.length() != 0) {
			size = Integer.parseInt(line.trim());
			map = new char[size][size];
			for (int i = 0; i < size; i++)
				map[i] = in.readLine().trim().toCharArray();
			int eagles = 0;
			for (int i = 0; i < size; i++)
				for (int j = 0; j < size; j++)
					if (map[i][j] == '1') {
						eagles++;
						floodFill(i, j);
					}
			out.append("Image number " + nCase++ + " contains " + eagles
					+ " war eagles.\n");
		}
		System.out.print(out);
	}