
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;




public class Codeforces    {
	
	 static class FastReader
	    {BufferedReader br; 
	        StringTokenizer st; 
	 public FastReader() 
	        {  br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	       String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    } 
      class Pair{
    	  int x;
    	  int y;
    	  public Pair(int a,int b)
    	  {
    		  x=a;
    		  y=b;
    	  }
      }
	 
	 
		
		
		public static void main(String[] args) {
		FastReader s=new FastReader();
		int t=s.nextInt();
		StringBuffer s1=new StringBuffer();
		while(t-->0)
		{
		
			
			int n=s.nextInt();
		 String[] a=new String[n];
		 
		 for(int i=0;i<n;i++)
			 a[i]=s.next();
		 
		 
		 char x=a[0].charAt(1);
		 char y=a[1].charAt(0);
		 char z=a[n-2].charAt(n-1);
		 char w=a[n-1].charAt(n-2);
		 
		 
		 if(x==y&&y==z&&y==w)
		 {
			System.out.println(2);
			System.out.println("1 2");
			System.out.println("2 1");
		 }else if(x==y)
		 {
			 if(y!=z&&y==w) {
				 System.out.println("1");
				 System.out.println((n-1)+" "+n);
				 }else if(y==z&&y!=w)
				 {
					 System.out.println("1");
					 System.out.println((n)+" "+(n-1));
				 }else if(y!=z&&y!=w)
				 {System.out.println("0");
				 }
		 }else if(z==w)
		 {
			 if(w!=x&&w==y)
			 {
				 System.out.println("1");
				 System.out.println("1 2");
			 }else if(w==x&&w!=y)
			 {
				 System.out.println("1");
				 System.out.println("2 1");
			 }else if(x!=z&&y!=z)
			 {System.out.println("0");
			 }
		 }else if(x!=y&&z!=w)
		 {
			 if(x==z) {
				 System.out.println("2");
			      System.out.println("1 2");
			      System.out.println(n-1+" "+n);
			 }else if(x==y)
			 {
				 System.out.println("2");
				 System.out.println("1 2");
				 System.out.println(n+" "+(n-1));
			 }
		 }
		 
			
		}
	    
	    
	    
	    
		}}
