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

/* Name of the class has to be "Main" only if the class is public. */
public class Bricks
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int t=0;
		if(sc.hasNextInt()==true)
		t=sc.nextInt();
		while(t-->0)
		{
		    int n=0;
		    n=sc.nextInt();
		    char mat[][]=new char[n][n];
		    for(int i=0;i<n;i++)
		    {
		        String str="";
		        str=sc.next();
		        for(int j=0;j<n;j++)
		        {
		            
		           
		            mat[i][j]=str.charAt(j);
		        }
		    }
		    
		    int num=0;
		    char ch1=mat[0][1];
		    char ch2=mat[1][0];
		    char ch3=mat[n-2][n-1];
		    char ch4=mat[n-1][n-2];
		    //Block
		    //0
		    if(ch1=='0'&& ch2=='0' && ch3=='0' && ch4=='0')
		    {
		        num=2;
		        System.out.println(num);
		        System.out.println(n-2 + " "+ (n-1));
		          System.out.println(n-1 + " "+ (n-2));
		    }
		    if(ch1=='1' && ch2=='1' && ch3=='1' && ch4=='1')
		    {
		        num=2;
		         System.out.println(num);
		        System.out.println(0 + " "+ 1);
		          System.out.println(1 + " "+ 0);
		    }
		    
		    if((ch1=='1' && ch2=='1' && ch3=='0' && ch4=='0') || (ch1=='0' && ch2=='0' && ch3=='1' && ch4=='1'))
		    System.out.println(0);
		    if(ch1=='0' && ch2=='0'&& (ch3!='0'|| ch4!='0'))
		    {
		        System.out.println(1);
		        if(ch3!=0)
		        System.out.println(n-1+" "+(n-2));
		        else
		         System.out.println(n-2+" "+(n-1));
		       
		    }
		    if(ch1=='1'&& ch2=='1'&&(ch3!='1'|| ch4!='1'))
		    {
		        System.out.println(1);
		        if(ch3!='1')
		          System.out.println(n-1+" "+(n-2));
		          else
		           System.out.println(n-2+" "+(n-1));
		    }
		    
		}
	}
}