import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class CF {
    public static void main (String[] args) {
	Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine();
        while (t-- > 0) {
            int n = sc.nextInt();
            sc.nextLine();
            String[] a = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextLine();
            }

            //System.out.println(Arrays.toString(a));

            char s1 = a[0].charAt(1);
            char s2 = a[1].charAt(0);
            char f1 = a[n-2].charAt(n-1); 
            char f2 = a[n-1].charAt(n-2); 
            int s1s2 =  Character.digit(s1, 10) + Character.digit(s2, 10); 
            int f1f2 =  Character.digit(f1, 10) + Character.digit(f2, 10);

            //System.out.println(s1s2 + ", " + f1f2);
            /*
            if (s1s2 == 0) {
                if (f1f2 == 0) {
                    System.out.println(2);
                    System.out.println("1 2");
                    System.out.println("2 1");
                } else if (f1f2 == 1) {
                    System.out.println(1);
                    if (f1 == '0') System.out.println((n-1) + " " + (n));
                    else System.out.println((n) + " " + (n-1));
                } else { //f1f2 must be two 
                    System.out.println(0);
                }
            } else if (s1s2 == 1) { // Make both s1s2 1s and make f1f2 0
                if (f1f2 == 0) { 
                    System.out.println(1);
                    if (s1 == '0') System.out.println("1 2");
                    else System.out.println("2 1");
                } else if (f1f2 == 1) {
                    System.out.println(2);
                    if (s1 == '0') System.out.println("1 2");
                    else System.out.println("2 1");
                    if (f1 == '1') System.out.println((n-1) + " " + (n));
                    else System.out.println((n) + " " + (n-1));
                } else { //f1f2 must be two 
                    System.out.println(1);
                    if (s1 == '1') System.out.println("1 2");
                    else System.out.println("2 1");
                }
            } else { // s1s2 must be two.
                if (f1f2 == 0) { // Already good.
                    System.out.println(0);
                } else if (f1f2 == 1) {
                    System.out.println(1);
                    if (f1 == '1') System.out.println((n-1) + " " + (n));
                    else System.out.println((n) + " " + (n-1));
                } else { //f1f2 must be two. FLip them to zero.
                    System.out.println(2);
                    System.out.println((n-1) + " " + (n));
                    System.out.println((n) + " " + (n-1));
                }
            }
            */

            // Case 1: We have combinations that differs by 2. All good
            if (Math.abs(s1s2-f1f2) == 2) {  
                System.out.println(0);
            // Case 2: We have combinations that differs by 0. 
            } else if (s1s2 == f1f2) {
                if (s1s2 == 2 || s1s2 == 0) { // Make s1s2 as 0
                    System.out.println(2);
                    System.out.println("1 2");
                    System.out.println("2 1");
                } else if (s1s2 == 1) { // Make s1s2 as 0 and f1f2 as 1
                    System.out.println(2);
                    if (s1 == '1') System.out.println("1 2");
                    else System.out.println("2 1");
                    if (f1 == '0') System.out.println((n-1) + " " + (n));
                    else System.out.println((n) + " " + (n-1));
                }
            // Case 2: We have combinations that differs by 1.
            } else { // We have a combination of (0,1) and (1,2)
                if (s1s2 == 1) {
                    if (f1f2 == 2) {
                        System.out.println(1);
                        if (s1 == '1') System.out.println("1 2");
                        else System.out.println("2 1");
                    } else if (f1f2 == 0) {
                        System.out.println(1);
                        if (s1 == '1') System.out.println("1 2");
                        else System.out.println("2 1");
                    }
                } else if (s1s2 == 0) {
                    if (f1f2 == 1) {
                        System.out.println(1);
                        if (f1 == '0') System.out.println((n-1) + " " + (n));
                        else System.out.println((n) + " " + (n-1));
                    }
                }
            }
        }

    }
}




