import java.util.Scanner;
public class cf676_2_2 {
	
	static char[] a;
	static char[] b;
	static char[] b1;
	static char[] a1;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0) {
			int n = sc.nextInt();
			String s[] = new String[n];
			for(int i=0;i<n;i++) {
				s[i] = sc.next();
			}
			
			for(int i=0;i<1;i++) {
				a = s[i].toCharArray();
				a1 = s[i+1].toCharArray();
			}
			//System.out.println(a[1] + " " + a1[0]);
			
			for(int i=n-1;i>n-2;i--) {
				b = s[i-1].toCharArray();
				b1 = s[i].toCharArray();
			}
			//System.out.println(b[n-2] + " " + b1[n-2]);
			
			if(a[1] != b[n-1] && a1[0] != b1[n-2]) {
				System.out.println(0);
			}else if(a[1] == b[n-1] && a1[0] == b1[n-2]) {
				System.out.println(2);
				System.out.println(1 + " " + 2);
				System.out.println(2 + " " + 1);
			}else {
				System.out.println(1);
				if(a[1] == b[n-1] && a1[0] != b1[n-2]) {
					System.out.println((n-1) + " " + (n));
				}else {
					System.out.println((n) + " " + (n-1));
				}
			}
		}
		sc.close();
	}

}
