import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException; 
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
 
 
 
    public class Codeforcesb {
        
       
 
        public static void main(String[] args) throws IOException {
           Scanner sc = new Scanner(System.in);
           int t = sc.nextInt();
           while(t-- >0){
              int n = sc.nextInt();
              char[][] arr = new char[n][n];
              for(int i = 0; i < n; i++){
                  String s = sc.next();
                  for(int j = 0; j < n; j++){
                      arr[i][j] = s.charAt(j);
                  }
              }
              int a = Character.getNumericValue(arr[0][1]);
              int b = Character.getNumericValue(arr[1][0]);
              int c = Character.getNumericValue(arr[n - 2][n-1]);
              int d = Character.getNumericValue(arr[n - 1][n - 2]);
              
              if(a != c && a!= d && b!= c && b != d){
                  System.out.println(0);
              }
              else if(a == c && a == d && b == c && b == d){
                  System.out.println(2);
                  System.out.println((n - 1) +" " + n);
                  System.out.println(n +" "+ (n - 1));
              }
              else {
                  if( a != b){
                      if(c != d){
                          System.out.println(2);
                          System.out.println(1 +" "+ 1);
                          System.out.println((n - 1) +" " + n);
                      }
                  }
                  else if(a == b && a == c || a == d){
                      if(a == c){
                          System.out.println(1);
                          System.out.println((n - 1) +" " + n);
                      }
                      else if(a == d){
                      System.out.println(1);
                      System.out.println(n +" " + (n - 1));
                  }
                  }
                  
                  
              }
              
              
           }
           
        }    
    }
 
 