
import java.util.*;

// import jdk.nashorn.internal.runtime.arrays.AnyElements;

import java.io.*;

public class Prb77 {


    static FastReader sc = new FastReader();

    public static void main(String[] args) {
      
        int t = sc.nextInt();
        while(t--!=0){
        
            int count0 = 0;
            int n = sc.nextInt();
            char a11 = 's',a21 = 's',amn = 's',anm = 's';
            for(int i = 0 ; i< n ; i++){
                String s = sc.next();
                if(i == 0){
                    a11 = s.charAt(1);
                }if(i == 1){
                    a21 = s.charAt(0);
                }if( i == n -2){
                    amn = s.charAt(n-1);
                }if( i == n - 1){
                    anm = s.charAt(n-2);
                }
            }
            if(a11 == '0'){
                count0++;
            }
            if(a21 == '0'){
                count0++;
            }
            if(amn == '0'){
                count0++;
            }
            if(anm == '0'){
                count0++;
            }
            if(anm == amn && anm == '1'){
                int count = 0;
                boolean one=false,two=false;
                if(a11 == '1'){
                    one = true;
                    count++;
                }
                if(a21 == '1'){
                    count ++;
                    two= true;
                } System.out.println(count);
                if(one){
                    System.out.println("1 2");
                }if(two){
                    System.out.println("2 1");
                }
            }else if(anm == amn && anm == '0'){
               
                    int count = 0;
                    boolean one=false,two=false;
                    if(a11 == '0'){
                        one = true;
                        count++;
                    }
                    if(a21 == '0'){
                        count ++;
                        two= true;
                    } System.out.println(count);
                    if(one){
                        System.out.println("1 2");
                    }if(two){
                        System.out.println("2 1");
                    }
                
            }
             else if ( count0 > 2){
                int count = 0;
                boolean one=false,two=false,three=false,four=false;
                if(a11 == '1'){
                    one = true;
                    count++;
                }
                if(a21 == '1'){
                    count ++;
                    two= true;
                }if(amn == '1'){
                    three = true;
                    count++;
                }
                if(anm == '1'){
                    count ++;
                    four= true;
                }
                System.out.println(count);
                if(one){
                    System.out.println("1 2");
                }if(two){
                    System.out.println("2 1");
                }if(four){
                    System.out.println((n-1)+" "+n);
                }if(three){
                    System.out.println(n+" "+(n-1));
                }
            }else if ( count0 < 2){
                int count = 0;
                boolean one=false,two=false,three=false,four=false;
                if(a11 == '0'){
                    one = true;
                    count++;
                }
                if(a21 == '0'){
                    count ++;
                    two= true;
                }if(amn == '0'){
                    three = true;
                    count++;
                }
                if(anm == '0'){
                    count ++;
                    four= true;
                }
                System.out.println(count);
                if(one){
                    System.out.println("1 2");
                }if(two){
                    System.out.println("2 1");
                }if(four){
                    System.out.println((n-1)+" "+n);
                }if(three){
                    System.out.println(n+" "+(n-1));
                }
            }

        }
     
            
    }

    

    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; 
        } 

        int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    } 


    
}