import java.io.*;
import java.util.*;
public class PushingBricksInTheWall{
	public static void main(String args[]){
		Scanner Sc=new Scanner(System.in);
		int T=Sc.nextInt();
		for(int i=0;i<T;i++){
			int N=Sc.nextInt();
			char [][]grid=new char[N][N];
			for(int j=0;j<N;j++){
				String inputLine=Sc.next();
				for(int k=0;k<N;k++){
					grid[j][k]=inputLine.charAt(k);
				}
			}
			int count=0;
			int p1x=-1;
			int p1y=-1;
			int p2x=-1;
			int p2y=-1;
			char SR=grid[0][1];//right of start
			char SD=grid[1][0];//down of start
			char FU=grid[N-2][N-1];//up of finish
			char FL=grid[N-1][N-2];//left of finish
			if(SR==SD){
				if(FU==SR){
					count++;
					p1x=N;
					p1y=N-1;
					//FU=(FU==1)?0:1;
				}
				if(FL==SR){
					count++;
					p2x=N-1;
					p2y=N;
					//FL=(FL==1)?0:1;
				}
			}else if(FL==FU){
				if(SR==FL){
					count++;
					p1x=1;
					p1y=2;
					//SR=(SR==1)?0:1;	
				}
				if(SD==FL){
					count++;
					p2x=2;
					p2y=1;
					//SR=(SR==1)?0:1;	
				}
			}else{
				if(SR!=1){
					count++;
					p1x=1;
					p1y=2;
				}
				if(SD!=1){
					count++;
					p1x=2;
					p1y=1;	
				}
				if(FU!=0){
					count++;
					p2x=N-1;
					p2y=N;	
				}
				if(FL!=1){
					count++;
					p2x=N;
					p2y=N-1;	
				}
			}
			if(count==0){
				System.out.println("0");
			}else if(count==1){
				System.out.println(count);
				if(p1x!=-1){
					System.out.println(p1x+" "+p1y);
				}else{
					System.out.println(p2x+" "+p2y);
				}
			}else{
				System.out.println(count);
				System.out.println(p1x+" "+p1y);
				System.out.println(p2x+" "+p2y);
			}
		}
	}
}