import java.util.*;

public class practicee{ 

	public static void main(String args[]) {
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		while(t-->0) {
			 int n=s.nextInt();
			 String arr[][]=new String[n+1][n+1];
			 for(int i=1;i<=n;i++) {
				 String str=s.next();
				 for(int j=1;j<=n;j++) {
					 arr[i][j]=str.charAt(j-1)+"";
				 }
			 }
			 
			 String a1=arr[1][2];
			 String a11=arr[2][1];
			 String b1=arr[n-1][n];
			 String b11=arr[n][n-1];
			 
			 if(a1.equals(a11) && b1.equals(b11)) {
System.out.println("1");
				 if(!a1.equals(b1)) {
					 System.out.println("0");
				 }else {
					 System.out.println("2");
					 System.out.println(1+" "+2);
					 System.out.println(2+" "+1);
				 }
			 }
			 else if(a1.equals(a11) && !b1.equals(b11)){
System.out.println("1");
				if(b1.equals(a1)) {
					System.out.println(n-1+" "+n);
				}else {
					System.out.println(n+" "+ (n-1));
				}
			 }	 
			 else if(b1.equals(b11) && !a1.equals(a11)){
					if(b1.equals(a1)) {
						System.out.println(1+" "+2);
					}else {
						System.out.println(2+" "+1);
					}
				 } else {
			 
				 System.out.println("2");
				 System.out.println(1+" "+2);
				 System.out.println(n-1+" "+n);
			 }
		 }
			
		
	}
}
