import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
public class Main {
public static void main(String[] args) {
    //solution start :-)
      Scanner sc = new Scanner(System.in);
		    int t = sc.nextInt();
		    while(t-->0) {
		    	ArrayList<Integer> al = new ArrayList<>();
		    	int n = sc.nextInt();
		    	String a[] = new String[n];
		    	for(int i=0;i<n;i++) {
		    		a[i] = sc.next();
		    	}
		    	char ch[][] = new char[n][n];
		    	for(int i=0;i<n;i++) {
		    		for(int j=0;j<n;j++) {
		    			ch[i][j] = a[i].charAt(i);
		    		}
		    	}
		    	int co1 = 0,co0 = 0;
		    	if(ch[2][0]=='1') co1++;
		    	else co0++;
		    	if(ch[1][1]=='1') co1++;
		    	else co0++;
		    	if(ch[0][2]=='1') co1++;
		    	else co0++;
		    	if(co1==3 && co0==0) {
		    		int co = 0;
		    		if(ch[1][0]=='1') co++;
		    		if(ch[0][1]=='1') co++;
		    		System.out.println(co);
		    		if(ch[1][0]=='1') System.out.println("2 1");
		    		if(ch[0][1]=='1') System.out.println("1 2");
		    	}
		    	else if(co1==0 && co0==3) {
		    		int co = 0;
		    		if(ch[1][0]=='0') co++;
		    		if(ch[0][1]=='0') co++;
		    		System.out.println(co);
		    		if(ch[1][0]=='0') System.out.println("2 1");
		    		if(ch[0][1]=='0') System.out.println("1 2");
		    	}
		    	else if(co1==1 && co0==2) {
		    		int co = 0;
		    		if(ch[1][0]=='1') co++;
		    		if(ch[0][1]=='1') co++;
		    		if(co==2 || co==1) {
		    			System.out.println(2-co+1);
		    			if(ch[1][0]=='0') System.out.println("2 1");
			    		if(ch[0][1]=='0') System.out.println("1 2");
		    			if(ch[2][0]=='1') System.out.println("3 1");
		    			else if(ch[1][1]=='1') System.out.println("2 2");
		    			else System.out.println("1 3");
		    		}
		    		else {
		    			System.out.println("2");
		    			if(ch[2][0]=='0') System.out.println("3 1");
		    			else if(ch[1][1]=='0') System.out.println("2 2");
		    			else System.out.println("1 3");
		    		}
		    	}
		    	else if(co1==2 && co0==1) {
		    		int co = 0;
		    		if(ch[1][0]=='0') co++;
		    		if(ch[0][1]=='0') co++;
		    		if(co==2 || co==1) {
		    			System.out.println(2-co+1);
		    			if(ch[1][0]=='1') System.out.println("2 1");
			    		if(ch[0][1]=='1') System.out.println("1 2");
		    			if(ch[2][0]=='0') System.out.println("3 1");
		    			else if(ch[1][1]=='0') System.out.println("2 2");
		    			else if(ch[0][2]=='0')  System.out.println("1 3");
		    		}
		    		else {
		    			System.out.println("2");
		    			if(ch[2][0]=='1') System.out.println("3 1");
		    			else if(ch[1][1]=='1') System.out.println("2 2");
		    			else System.out.println("1 3");
		    		}
		    	}
		    }
		
    //	solution end \(^-^)/
    //		        |
    //		       / \
}}