

import java.io.*;
import java.math.*;
import java.util.*;


// @author : Dinosparton [ SHIVAM BHUVA ]

public class test {
	 
	   static class Pair{ 
		   int x;
		   int y;
		   
		   Pair(int x,int y){ 
			   this.x = x;
			   this.y = y;
			   
		   }
	   }
	  
	   static class Compare { 
		   
		     void compare(Pair arr[], int n) 
		    { 
		        // Comparator to sort the pair according to second element 
		        Arrays.sort(arr, new Comparator<Pair>() { 
		            @Override public int compare(Pair p1, Pair p2) 
		            { 
		                return p1.x - p2.x; 
		            } 
		        }); 
		  
//		        for (int i = 0; i < n; i++) { 
//		            System.out.print(arr[i].x + " " + arr[i].y + " "); 
//		        } 
//		        System.out.println(); 
		    } 
		} 
	  
	   
	   
	   public static void main(String args[]) { 
		
		  Scanner sc = new Scanner(System.in);
		  
		  StringBuffer ans = new StringBuffer();
		  
		  int tc = sc.nextInt();
		  
		  while(tc-->0) { 
			  
			 int n = sc.nextInt();
			 
			 char c[][] = new char[n][n];
			 
			 for(int i=0;i<n;i++) { 
				 String s = sc.next();
				 
				 for(int j=0;j<n;j++) { 
					 c[i][j] = s.charAt(j);
				 }
			 }
			 
			  if((c[0][1]==c[1][0]) && (c[n-2][n-1]==c[n-1][n-2]) && c[0][1]!=c[n-2][n-1])
				 System.out.println(0);
			 else if((c[0][1]==c[1][0]) && (c[n-2][n-1]==c[n-1][n-2]) && c[0][1]==c[n-2][n-1]) { 
				 System.out.println(1);
				 System.out.println(1+" "+2);
				 System.out.println(2+" "+1);
			 }
			 else if((c[0][1]==c[1][0]) && (c[n-2][n-1]!=c[n-1][n-2]) && c[0][1]==c[n-2][n-1]) { 
				 System.out.println(1);
				 System.out.println((n-1)+" "+n);
			 }
			 else if((c[0][1]==c[1][0]) && (c[n-2][n-1]!=c[n-1][n-2]) && c[0][1]!=c[n-2][n-1]) { 
				 System.out.println(1);
				 System.out.println(n+" "+(n-1));
			 }
			 else if((c[0][1]!=c[1][0]) && (c[n-2][n-1]==c[n-1][n-2]) && c[0][1]==c[n-2][n-1]) { 
				 System.out.println(1);
				 System.out.println(1+" "+2);
			 } 
			 else if((c[0][1]!=c[1][0]) && (c[n-2][n-1]==c[n-1][n-2]) && c[0][1]!=c[n-2][n-1]) { 
				 System.out.println(1);
				 System.out.println(2+" "+1);
			 } 
		  }
		  
		  System.out.println(ans);
	   }  
}  




