import java.util.*;
import java.lang.*;
import java.io.*;

public class Codeforces {
    static FastReader sc=new FastReader();
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		int t=I();
		while(t-->0)
		{
			int n=I();
			char c[][]=new char[n][n];
			for(int i=0;i<n;i++)
			{
				String s=S();
				for(int j=0;j<n;j++)
				{
					c[i][j]=s.charAt(j);
				}
			}
			StringBuffer sb=new StringBuffer();
			char x=c[0][1],y=c[1][0],z=c[n-2][n-1],w=c[n-1][n-2];
			if(x==y)
			{
				if(x=='0')
				{
					if(z==w && z=='0')
					{
						sb.append("2\n");
						sb.append(n+" "+(n-1)+"\n");
						sb.append((n-1)+" "+n+"\n");
					}
					else if(z==w && z=='1')
					{
						sb.append("0\n");
					}
					else if(z!=w)
					{
						sb.append("1\n");
						if(z!='1')
						sb.append((n-1)+" "+n+"\n");
						else
						sb.append(n+" "+(n-1)+"\n");
					}
				}
				else if(x=='1')
				{
					if(z==w && z=='0')
					{
						sb.append("0\n");
					}
					else if(z==w && z=='1')
					{
						sb.append("2\n");
						sb.append(n+" "+(n-1)+"\n");
						sb.append((n-1)+" "+n+"\n");
					}
					else if(z!=w)
					{
						sb.append("1\n");
						if(z!='0')
						sb.append((n-1)+" "+n+"\n");
						else
						sb.append(n+" "+(n-1)+"\n");
					}
				}
			}
			else
			{
				if(z==w && z=='0')
				{
					sb.append("1\n");
					if(x!='1')
					sb.append("1 2\n");
					else
					sb.append("2 1\n");
				}
				else if(z==w && z=='1')
				{
					sb.append("1\n");
					if(x!='0')
					sb.append("1 2\n");
					else
					sb.append("2 1\n");
				}
				else
				{
					sb.append("2\n");
					if(x!='0')
					sb.append("1 2\n");
					else
					sb.append("2 1\n");
					if(z!='1')
					sb.append((n-1)+" "+n+"\n");
					else
					sb.append(n+" "+(n-1)+"\n");
				}
			}
			System.out.print(sb.toString());
		}
	}
	public static ArrayList<Integer> prime(int n)
	{
	    ArrayList<Integer> arr=new ArrayList<>();
	    boolean prime[] = new boolean[n + 1];
        for (int i = 0; i <= n; i++)
        prime[i] = true;
        for (int p = 2; p * p <= n; p++)
        {
            if (prime[p] == true)
            {
                for (int i = p * p; i <= n; i += p)
                prime[i] = false;
            }
        }
        for (int i = 2; i <= n; i++)
        {
            if (prime[i] == true)
            arr.add(i);
        }
        return arr;
	}
	public static class DSU
	{
	    static int par[],rank[];
	    public DSU(int c)
	    {
	        par=new int[c+1];
	        rank=new int[c+1];
	        for(int i=0;i<=c;i++)
	        {
	            par[i]=i;
	            rank[i]=0;
	        }
	    }
	    public static int find(int a)
	    {
	        if(a==par[a])
	        return a;
	        return par[a]=find(par[a]);
	    }
	    public static void union(int a,int b)
	    {
	        int a_rep=find(a),b_rep=find(b);
	        if(a_rep==b_rep)
	        return;
	        if(rank[a_rep]<rank[b_rep])
	        par[a_rep]=b_rep;
	        else if(rank[a_rep]>rank[b_rep])
	        par[b_rep]=a_rep;
	        else
	        {
	            par[b_rep]=a_rep;
	            rank[a_rep]++;
	        }
	    }
	}
	public static class pair
    {
    	long a;
    	int b;
    	public pair(long val,int index)
    	{
    	    a=val;
    	    b=index;
    	}
    }
    public static class myComp implements Comparator<pair>
    {
    	public int compare(pair p1,pair p2)
    	{
    	    if(p1.a==p2.a)
    	    return 0;
    	    else if(p1.a<p2.a)
    	    return -1;
    	    else
    	    return 1;
    	}
    }
	public static class pair1
    {
    	long a;
    	long b;
    	public pair1(long val,long index)
    	{
    	    a=val;
    	    b=index;
    	}
    }
    public static ArrayList<pair1> mergeIntervals(ArrayList<pair1> arr)
	{
	    //****************use this in main function-Collections.sort(arr,new myComp());
	    ArrayList<pair1> a1=new ArrayList<>();
	    if(arr.size()<=1)
	    return arr;
	    a1.add(arr.get(0));
	    int i=1,j=0;
	    while(i<arr.size())
	    {
	        if(a1.get(j).b<arr.get(i).a)
	        {
	           a1.add(arr.get(i));
	           i++;
	           j++;
	        }
	        else if(a1.get(j).b>arr.get(i).a && a1.get(j).b>=arr.get(i).b)
	        {
	            i++;
	        }
	        else if(a1.get(j).b>=arr.get(i).a)
	        {
	            long a=a1.get(j).a;
	            long b=arr.get(i).b;
	            a1.remove(j);
	            a1.add(new pair1(a,b));
	            i++;
	        }
	    }
	    return a1;
	}
	public static long countDigit(long n)
	{
	    long sum=0;
	    while(n!=0)
	    {
	        sum++;
	        n=n/10;
	    }
	    return sum;
	}
	public static long digitSum(long n)
	{
	    long sum=0;
	    while(n!=0)
	    {
	        sum=sum+n%10;
	        n=n/10;
	    }
	    return sum;
	}
	public static long gcd(long a,long b)
	{
	    if(b==0)
	    return a;
	    else
	    return gcd(b,a%b);
	}
    public static int I(){return sc.I();}
    public static long L(){return sc.L();}
    public static String S(){return sc.S();}
    public static double D(){return sc.D();}
}
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 I(){ 
        return Integer.parseInt(next());
    }
    long L(){ 
        return Long.parseLong(next());
    }
    double D(){
         return Double.parseDouble(next());
    }
    String S(){
        String str = "";
        try 
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}