import java.io.*;
import java.util.*;

public class A
{
    static int n;
    static int[] arr;
    static char[][] s;
    public static void main(String[] args) throws IOException
    {
        Flash f = new Flash();
        int T = f.ni();
        for(int tc = 1; tc <= T; tc++){
            n = f.ni();
            s = new char[n][];
            for(int i = 0; i < n; i++){
                s[i] = f.ns().toCharArray();
            }
            
            fn();
        }
    }
    
    static void fn()
    {
        List<int[]> ans = new ArrayList<>();
        if(dfs('0', 0, 0, new boolean[n][n])){
            if(s[1][0] == '0'){
                ans.add(new int[]{2, 1});
            }
            
            if(s[0][1] == '0'){
                ans.add(new int[]{1, 2});
            }
        }
        
        if(dfs('1', 0, 0, new boolean[n][n])){
            if(s[1][0] == '1'){
                ans.add(new int[]{2, 1});
            }
            
            if(s[0][1] == '1'){
                ans.add(new int[]{1, 2});
            }
        }
        
        sop(ans.size());
        for(int[] a : ans) sop(a[0] + " " + a[1]);
    }
    
    static boolean dfs(char d, int r, int c, boolean[][] vis){
        if(r == n-1 && c == n-1) return true;
        vis[r][c] = true;
        int[] dx = {-1, 1, 0, 0};
        int[] dy = {0, 0, -1, 1};
        for(int i = 0; i < 4; i++){
            int x = r+dx[i];
            int y = c+dy[i];
            if(x >= 0 && x < n && y >= 0 && y < n && !vis[x][y] && (s[x][y] == d || s[x][y] == 'F') && dfs(d, x, y, vis)){
                return true;
            }
        }
        
        vis[r][c] = false;
        return false;
    }
    
    static void sort(int[] a){
        List<Integer> A = new ArrayList<>();
        for(int i : a) A.add(i);
        Collections.sort(A);
        for(int i = 0; i < A.size(); i++) a[i] = A.get(i);
    }
    
    static int swap(int itself, int dummy){
        return itself;
    }
    
    static void sop(Object o){ System.out.println(o); }
    
    static void print(int[] a){
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < a.length; i++) sb.append(a[i] + " ");
        System.out.println(sb);
    }
    
    static class Flash
    {
        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();
        }
        
        String ns(){
            String s = new String();
            try{
                s = br.readLine().trim();
            }catch(IOException e){
                e.printStackTrace();
            }
            
            return s;
        }
        
        int ni(){
            return Integer.parseInt(next());
        }
        
        int[] arr(int n){
            int[] a = new int[n];
            for(int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

        long nl(){
            return Long.parseLong(next());
        }
        
        double nd(){
            return Double.parseDouble(next());
        }
    }
}