import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.math.*;



public class A {


    public static void main(String[] args) {
    
    	FastScanner scan = new FastScanner();
    	
    	int t = scan.nextInt();
    	for(int tt=0; tt<t; tt++) {
    		
    		int n = scan.nextInt();
    		char [][] board = new char[n][n];
    		for(int i=0; i<n; i++) {
    			char [] ch = scan.next().toCharArray();
    			for(int j=0; j<n; j++) board[i][j]= ch[j];
    		}
    		int start1 = board[1][0], start2 = board[0][1], end1 = board[n-2][n-1], end2 = board[n-1][n-2];
    		int count = 0;
    		ArrayList<Integer> arr = new ArrayList<>();
    		// all are equal
    		if(start1 == start2 && end1 == end2 && start2 == end1) {
    			count = 2;
    			arr.add(2); arr.add(1); arr.add(1); arr.add(2);
    		} else if(start1 != start2 && end1 != end2) {
    			//2 are equal 
    			count = 2;
    			if(start1 == end1) {
    				arr.add(1); arr.add(2); arr.add(n); arr.add(n-1);
    			} else {
    				arr.add(2); arr.add(1); arr.add(n-1); arr.add(n);
    			}
    		} else if((start1 == start2 && end1 != end2) || (start1 != start2 && end1 == start2)) {
    			// 3 are equal
    			count = 1;
    			if(start1 != start2) {
    				if(start1 == end1) {
    					arr.add(2); arr.add(1);
    				} else {
    					arr.add(1); arr.add(2);
    				}
    			} else {
    				if(end1 == start1) {
    					arr.add(n-1); arr.add(n);
    				} else {
    					arr.add(n); arr.add(n-1);
    				}
    			}
    		}
    		System.out.println(count);
    		for(int i=0; i<arr.size(); i++) {
    			System.out.print(arr.get(i) + " ");
    			if(i !=0 && i % 2 ==1) System.out.println();
    		}
    		
    	}
    }	
    	
    
    
    
    public static void sort(int [] a) {
    	ArrayList<Integer> b = new ArrayList<>();
    	for(int i: a) b.add(i);
    	Collections.sort(b);
    	for(int i=0; i<a.length; i++) a[i]= b.get(i);
    }
  
    static class FastScanner{
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
    	String next() {
    		while(!st.hasMoreTokens())
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e){
    				e.printStackTrace();
    			}
    		return st.nextToken();
    	}
    	
    	int nextInt() {
    		return Integer.parseInt(next());
    	}
    	
    	int [] readArray(int n) {
    		int [] a = new int[n];
    		for(int i=0; i<n ; i++) a[i] = nextInt();
    		return a;
    	}
    	
    	long nextLong() {
    		return Long.parseLong(next());
    	}
    	
    	
    }
    
   
}

