public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int caseCount = 1;
		int totalCases = Integer.parseInt(in.nextLine());
		StringBuilder results = new StringBuilder();
		
		for(; caseCount <= totalCases; caseCount++){
			int gridSize = Integer.parseInt(in.nextLine());
			String[][] grid = new String[gridSize][gridSize];
			int blackCount = 0;
			for (int i = 0; i < gridSize;i++) {
				String line = in.nextLine();
				for (int j = 0; j < gridSize;j++ ) {
					grid[i][j] = line.substring(j,j+1);
					if(grid[i][j].equals("#")){
						blackCount++;
					}
				}
			}
			if((blackCount == 1) || hasSquare(grid, caseCount)){
				results.append("Case #" + caseCount+ " YES");
			}else{
				results.append("Case #" + caseCount+ " NO");
			}
			if(caseCount != totalCases)
				results.append("\n");
		}
		System.out.print(results);
	}