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

public class B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			FastScanner sc = new FastScanner();
			
			int t  = sc.nextInt();
			
			while(t > 0) {
				
				int n = sc.nextInt();
				int res = 0;
				
				String[] s = new String[n];
				
				for (int i = 0; i < n; i++) {
					s[i] = sc.next();
					
				}
				List<int[]> sol = new ArrayList<>();
				
				char c1 = s[0].charAt(1);
				char c2 = s[1].charAt(0);
				char c3 = s[n - 2].charAt(n - 1);
				char c4 = s[n - 1].charAt(n - 2);
				
				
				if(c1 == c2) {
					
					if(c3 == c1) {
						res++;
						sol.add(new int[] {n-1 , n});
					}
					if(c4 == c1) {
						res++;
						sol.add(new int[] {n, n - 1});
					}
					
				}
				
				else {
					res += 2;
					if(c1 == c3) {
						sol.add(new int[] {1 , 2});
						sol.add(new int[] {n , n - 1});
						
					}
					
					else if(c1 == c4) {
						sol.add(new int[] {1 , 2});
						sol.add(new int[] {n - 1 , n});
						
					}
					
				}
				System.out.print(res);
				System.out.println();
				for(int[] curr : sol) {
					System.out.print(curr[0] + " "+ curr[1]);
					System.out.println();
				}
				
				t--;
			}
			
			

	}
	
	static class FastScanner {
		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();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}
