import java.util.Scanner;
import java.util.Arrays;
public class contest18102{
	static Scanner scan = new Scanner(System.in);
	static int t = scan.nextInt();
	public static void main(String[] args){
		for(int i=0; i<t; i++){
			int n = scan.nextInt();
			String[] sarr = new String[n];
			for(int j=0; j<n; j++){
				sarr[j]=scan.next();
			}
			String[][] arr = new String[n][n];
			for(int j=0; j<n; j++){
				arr[j] = sarr[j].split("");
			}
			int ic=0;
			boolean a = false;
			if(arr[0][1].equals(arr[1][0])){
				a=true;
			}
			boolean b = false;
			if(arr[n-2][n-1].equals(arr[n-1][n-2])){
				b=true;
			}
			boolean c = false;
			if(arr[0][1].equals(arr[n-1][n-2])){
				c=true;
			}
			if(a){
				if(b){
					if(c){
						System.out.println(2);
						System.out.println(1+" "+2);
						System.out.println(2+" "+1);
					}else{
						System.out.println(0);
					}
				}else{
					if(c){
						System.out.println(1);
						System.out.println(n+" "+(n-1));
					}else{
						System.out.println(1);
						System.out.println((n-1)+" "+n);
					}
				}
			}else{
				if(b){
					if(c){
						System.out.println(1);
						System.out.println(1+" "+2);
					}else{
						System.out.println(1);
						System.out.println(2+" "+1);
					}
				}else{
					if(c){
						System.out.println(2);
						System.out.println(1+" "+2);
						System.out.println(n+" "+(n-1));
					}else{
						System.out.println(2);
						System.out.println(1+" "+2);
						System.out.println((n-1)+" "+n);
					}
				}
			}
		}
	}
}