/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class B
{
	public static void main (String[] args) throws java.lang.Exception
	{
		try {

		    Scanner sc = new Scanner(System.in);

		    int t = sc.nextInt();
		    while(t-->0){
				int n = sc.nextInt();

				int a = -1, b=-1, c=-1,d=-1;

				for(int i = 1; i<=n; i++) {
					String s  = sc.next();

					if( i == 1 && a == -1) {
						a = s.charAt(1)-'0';
					}
					 if( i == 2 && b == -1 ) {
						b = s.charAt(0)-'0';
					}
					if( i == n-1 && c == -1) {
						c = s.charAt(n-1)-'0';
					}
					if( i == n && d == -1 ) {
						d = s.charAt(n-2)-'0';
					}


				}

//				System.out.println("a = "+a+" b = "+b+" c = "+c+" d = "+d);




				ArrayList<int[]> list = new ArrayList();


				if( a == b) {
					if( c == a ) list.add(new int[]{n-1, n});
					if( d == a) list.add(new int[]{n, n-1});
				}
				else if( c == d) {
					if( c == a ) list.add(new int[]{1, 2});
					if( c == a) list.add(new int[]{2, 1});
				}
				else {
					list.add(new int[]{1, 2});
					if( b == c ) list.add(new int[]{n-1, n});
					if( b == d ) list.add(new int[]{n, n-1});
				}


				System.out.println(list.size());
				for(int i[] : list){
					System.out.println(i[0] + " "+i[1]);
				}


				}






		} catch(Exception e) {
		} finally {
		}
	}
}
