import java.util.*;
import java.io.*;
public class EdB {
	static long num = 998244353;
	public static void main(String[] args) throws Exception{
		

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int t = Integer.parseInt(bf.readLine());
 		for(int i = 0;i<t;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int n = Integer.parseInt(bf.readLine());
	 		char[][] grid = new char[n][n];
	 		for(int j =0 ;j<n;j++){
	 			grid[j] = bf.readLine().trim().toCharArray();
	 		}
	 		
	 		if ((grid[0][1] == '0' && grid[1][0] == '0') || (grid[0][1] == '1' && grid[1][0] == '1')){
	 				int count =0 ;
	 				for(int j = 0;j<=2;j++){
	 					if (grid[j][2-j] == grid[0][1]){
	 						count++;
	 					}
	 				}
	 				out.println(count);
	 				for(int j = 0;j<=2;j++){
	 					if (grid[j][2-j] == grid[0][1]){
	 						out.println((j+1) + " " + (3-j));
	 					}
	 				}
	 		}
	 		else{
	 			int ones = 0;
	 			int zero = 0;
	 			for(int j = 0;j<=2;j++){
 					if (grid[j][2-j] == '0'){
 						zero++;
 					}
 					else
 						ones++;
 				}
	 			if (zero > ones){
	 				int count = 0;
	 				for(int j =0;j<=1;j++){
	 					if (grid[j][1-j] == '1')
	 						count++;
	 				}
	 				for(int j =0;j<=2;j++){
	 					if (grid[j][2-j] == '0')
	 						count++;
	 				}
	 				out.println(count);
	 				for(int j =0;j<=1;j++){
	 					if (grid[j][1-j] == '1'){
	 						out.println((j+1)+" " + (2-j));
	 					}
	 				}
	 				for(int j =0;j<=2;j++){
	 					if (grid[j][2-j] == '0'){
	 						out.println((j+1)+" "+(3-j));
	 					}
	 				}
	 			}
	 		}
	 	}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	


