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

public class Main {
    public static void wall(String[][] arr, int n) {
        // for(int i = 0; i < arr.length; i++) {
        //     System.out.println(Arrays.toString(arr[i]));
        // }
        String x = arr[0][1];
        String y = arr[1][0]; 
        String w = arr[n-1][n-2];
        String z = arr[n - 2][n - 1];
       
        int count = 0;
        List<Integer> list = new ArrayList<>();
        if(x.equals(y) && w.equals(z) && !x.equals(w)) {
            System.out.println(0);
            return;
        }else if(x.equals(y) && !w.equals(z)) {
            if(x.equals(w)) {
                list.add(n);
                list.add(n-1);
                count++;
            } else {
                list.add(n-1);
                list.add(n);
                count++;
            }
        } else if(!x.equals(y) && w.equals(z)) {
            if(x.equals(w)) {
                list.add(1);
                list.add(2);
                count++;
            } else {
                list.add(2);
                list.add(1);
                count++;
            }
        } else if(!x.equals(y) && !w.equals(z)) {
            list.add(1);
            list.add(2);
            list.add(n);
            list.add(n-1);
            count = 2;
        } else if (x.equals(y) && w.equals(z) && x.equals(w)) {
            list.add(1);
            list.add(2);
            list.add(2);
            list.add(1);
            count = 2;
        }

        System.out.println(count);
        int j = 1;
        for(int i = 0; i < list.size(); i++) {
            if(j%2==0) System.out.println(list.get(i) +" ");
            else System.out.print(list.get(i) + " ");
            j++;
        }
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String file = "./input.txt";
        //BufferedReader br = new BufferedReader(new FileReader(file));
        int t = Integer.parseInt(br.readLine());
        while(t-->0) {
            int n = Integer.parseInt(br.readLine());
            String[][] arr = new String[n][n];
            for(int i = 0; i < n; i++) {
                String[] row = br.readLine().split("");
                for(int j = 0; j < row.length; j++) {
                    arr[i][j] = row[j];
                }
            }
            wall(arr, n);
        }
    }
}