//    A Computer is Like a mischievous genie.
//    It will give you exactly what you ask for,
//    but not always what you want
//    A code by Rahul Verma

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;


public class Main {

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

  static class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new
          InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String[] nextSArray() {
      String sr[] = null;
      try {
        sr = br.readLine().trim().split(" ");
      } catch (IOException e) {
        e.printStackTrace();
      }
      return sr;
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }

      return str;
    }
  }


  static long powmodulo(long a, long p) {
    if (p == 0)
      return 1 % mod;
    if (p == 1)
      return a % mod;
    long ans = 1;
    while (p > 0) {
      if ((p & 1) > 0) {
        ans = (ans * a) % mod;
      }
      a = (a * a) % mod;
      p = p >> 1;
    }
    return ans % mod;
  }




  static long mod = 1000000007;

  static long gcd(long a,long b)
  {
    if(a==0)
      return b;
    return  gcd(b%a,a);
  }

  static long fast_powerNumbers(long a,long n)
  {
    if(n==1)
      return a;
    long ans=fast_powerNumbers(a,n/2);
    if(n%2==0)
      return (ans*ans);
    else
      return ((ans*ans)*(a));
  }

  static HashMap<Integer,ArrayList<Integer>>hmm;
  static  int visited[];
  static void dfs_helper(int root,int team)
  {
    ArrayList<Integer>al=hmm.get(root);

    visited[root]=team;
    for (Integer i :al)
    {
      if(visited[i]==0)
        dfs_helper(i,team);
    }
  }

  static void dfs(int n,int u,int team)
  {
        dfs_helper(u,team);

  }


  public static void main(String[] args) throws Exception {
    FastReader sc = new FastReader();
    int t1=sc.nextInt();
    for (int t = 0; t < t1; t++) {

      int n=sc.nextInt();
      char arr[][]=new char[n][n];
      for (int i = 0; i < n ; i++) {
        String k=sc.nextLine();
        for (int j = 0; j <n ; j++) {
          arr[i][j]=k.charAt(j);
        }
      }
      char a,b,c,d;
      a = arr[1][0];
      b = arr[0][1];
      c = arr[n-2][n-1];
      d = arr[n-1][n-2];
      //System.out.println(a+" "+b+" "+c+" "+d);
      int ans=0;
      ArrayList<Pair>al=new ArrayList<>();
      if(a==b)
      {
        if(a=='1')
        {
          if(c=='1')
          {
            ++ans;
            al.add(new Pair(n-1,n));
          }
          if(d=='1')
          {
            ++ans;
            al.add(new Pair(n,n-1));
          }
        }
        else
        {
          if(c=='0')
          {
            ++ans;
            al.add(new Pair(n-1,n));
          }
          if(d=='0')
          {
            ++ans;
            al.add(new Pair(n,n-1));
          }
        }
      }
      else
      {
        int one=0,zero=0;
        if(a=='1')
          ++one;
        if(a=='0')
          ++zero;
        if(b=='1')
          ++one;
        if(b=='0')
          ++zero;
        if(c=='1')
          ++one;
        if(c=='0')
          ++zero;
        if(d=='1')
          ++one;
        if(d=='0')
          ++zero;

        char changed='0';
        if(one<zero)
          changed='1';

        if(a==changed)
        {
          ++ans;
          al.add(new Pair(2,1));
        }
        if(b==changed)
        {
          ++ans;
          al.add(new Pair(1,2));
        }
        if(c==changed)
        {
          ++ans;
          al.add(new Pair(n-1,n));
        }
        if(d==changed)
        {
          ++ans;
          al.add(new Pair(n,n-1));
        }







      }

      out.println(ans);
      for (int i = 0; i <ans ; i++) {
        out.println(al.get(i).a+" "+al.get(i).b);
      }
      }
    out.close();


  }}


class Pair
{
  int a; int b;
  Pair(int a,int b)
  {
    this.a=a;
    this.b=b;
  }
}


class Graph
{
  HashMap<Integer,ArrayList<Integer>>hm;
  Graph()
  {
    hm=new HashMap<>();
  }
  Graph(int n){

    hm=new HashMap<>();
    for (int i = 0; i <n ; i++) {
      hm.put(i,new ArrayList<Integer>());
    }
  }
  // function for adding an edge.................................................
  public void addEdge(int a,int b,boolean isDir)
  {
    if(isDir)
    {
      if(hm.containsKey(a))
      {
        hm.get(a).add(b);
      }
      else
      {
        hm.put(a,new ArrayList<>(Arrays.asList(b)));
      }
    }
    else
    {
      if(hm.containsKey(a))
      {
        hm.get(a).add(b);
      }
      else if(!hm.containsKey(a))
      {
        hm.put(a,new ArrayList<>(Arrays.asList(b)));
      }

      if(hm.containsKey(b))
      {
        hm.get(b).add(a);
      }
      else if(!hm.containsKey(b))
      {
        hm.put(b,new ArrayList<>(Arrays.asList(a)));
      }
    }
  }



}

// out.println(al.toString().replaceAll("[\\[|\\]|,]",""));

