public static void main(String[] args) {
		try{
			BufferedReader reader = new BufferedReader(new FileReader(new File("FB_HackerCup/input.txt")));
			PrintWriter writer = new PrintWriter(new FileWriter(new File("FB_HackerCup/output.txt")));
			SquareDetector sd = new SquareDetector();
			
			String temp = reader.readLine();
			int T = Integer.parseInt(temp.trim());
			for(int i = 1; i <= T; i++) {
				int N = Integer.parseInt(reader.readLine().trim());
				ArrayList<String> list = new ArrayList<String>();
				for(int j = 0; j < N; j++) {
					list.add(reader.readLine());
				}
				if(sd.allSquare(N, list)) {
					writer.println("Case #" + i + ": YES");
				} else {
					writer.println("Case #" + i + ": NO");
				}
			}
			
			reader.close();
			writer.close();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}