import com.sun.source.tree.Tree;

import javax.naming.spi.DirObjectFactory;
import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;


import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.nio.file.LinkOption;
import java.util.*;


public class Main {

   static boolean vis[][];
   static boolean vis2[][];
   static char[][]a;
   static boolean reach(int row,int col,int type){
        if (row>=vis.length||col>=vis.length)return false;
        if (a[row][col]=='F')return true;
        if (vis[row][col]||(a[row][col]!='S'&&(a[row][col]-'0')!=type))return false;
        vis[row][col]=true;
        boolean state=false;
       state|= reach(row+1,col,type);
        state|=reach (row,col+1,type);
        return state;
    }

    static boolean reach2(int row,int col,int type){
        if (row>=vis2.length||col>=vis2.length)return false;
        if (a[row][col]=='F')return true;

        if (vis2[row][col]||(a[row][col]!='S'&&(a[row][col]-'0')!=type))return false;
        vis2[row][col]=true;
        boolean state = reach2(row + 1, col, type);
        state|=reach2(row,col+1,type);
        return state;
    }



    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);


        try (PrintWriter or = new PrintWriter(System.out)) {

            int t = in.nextInt();
            outer:
            while (t-- > 0) {


               int n = in.nextInt();
               a=new char[n][n];
                for (int i = 0; i < n; i++) {
                    a[i]=in.next().toCharArray();
                }
                vis=new boolean[n][n];
                vis2=new boolean[n][n];
                boolean one=reach2(0,0,1);
                boolean zero=reach(0,0,0);
                int one1=0,zero1=0;
                if (a[n-2][n-2]=='0')++zero1;
                else ++one1;

                if (a[n-2][n-1]=='0')++zero1;
                else ++one1;

                if (a[n-1][n-2]=='0')++zero1;
                else ++one1;


                if (one){
                    one1=Math.min(one1,2);
                    or.println(one1);
                        

                        if (one1>0&&a[n - 1][n - 2] == '1'){
                            --one1;
                            or.println((n) + " " + (n - 1));
                        }
                        if (one1>0&&a[n - 2][n - 1] == '1'){
                            or.println((n - 1) + " " + (n));
                        }
                    if (one1>0&&a[n - 2][n - 2] == '1'){
                        --one1;
                        or.println((n - 1) + " " + (n - 1));
                    }

                }
                else if (zero){
                    zero1=Math.min(zero1,2);
                    or.println(zero1);
                        
                    if (zero1>0&&a[n-1][n-2]=='0'){
                        --zero1;
                        or.println((n)+" "+(n-1));
                    }

                    if (zero1>0&&a[n-2][n-1]=='0'){
                        --zero1;
                        or.println((n-1)+" "+(n));
                    }
                    if (zero1>0&&a[n-2][n-2]=='0'){
                        or.println((n-1)+" "+(n-1));
                    }
                }else or.println(0);












            }
        }


    }

    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

}


