/* package codechef; // don't place package name! */

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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-->0){
		    int n = s.nextInt();
		    char[][] arr = new char[n][n];
		    for(int i=0;i<n;i++){
		        arr[i] = s.next().toCharArray();
		    }
		    int count = 0;
		    if(arr[0][1] == arr[1][0] && arr[n-1][n-2] == arr[n-2][n-1] && arr[0][1] == arr[n-1][n-2]){
		        System.out.println(2);
		        System.out.println("1 0");
		        System.out.println("0 1");
		    }
		    else if(arr[0][1] != arr[1][0]){
		        if(arr[n-1][n-2] == arr[n-2][n-1]){
		            if(arr[n-1][n-2] == arr[0][1]){
		                System.out.println(1);
		                System.out.println("0 1");
		            }
		            else{
		                System.out.println(1);
		                System.out.println("1 0");
		            }
		        }
		        else{
		            if(arr[0][1] == arr[n-1][n-2]){
		                System.out.println(2);
		                System.out.println("1 0");
		                System.out.println((n-1)+" "+(n-2));
		            }
		            else if(arr[0][1] == arr[n-2][n-1]){
		                System.out.println(2);
		                System.out.println("1 0");
		                System.out.println((n-2)+" "+(n-1));
		            }
		        }
		    }
		    else if(arr[0][1] == arr[1][0]){
		        if(arr[n-1][n-2] != arr[n-2][n-1]){
		            if(arr[n-1][n-2] == arr[0][1]){
		                System.out.println(1);
		                System.out.println("0 1");
		            }
		            else{
		                System.out.println(1);
		                System.out.println("1 0");
		            }
		        }
		        else{
		            if(arr[n-1][n-2]!=arr[0][1])System.out.println(0);
		        }
		    }
		}
	}
}
