#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================
void solve() {
  ll i,j,k,n,m,ans=0,count = 0;
  cin>>n;
  char a[n][n];
  fo(i,n)fo(j,n)cin>>a[i][j];
  char b,c,d,e;
  b = a[1][0];
  c = a[0][1];
  d = a[n-1][n-2];
  e = a[n-2][n-1];
  if(b==c){
    if(d==e){
      if(d!=b){
        cout<<"0\n";
      }
      else{
        cout<<"2\n";
        cout<<"1 2\n2 1\n";
      }
    }
    else {
      cout<<"1\n";
      if(b==d){
        cout<<n<<" "<<n-1<<"\n";
      }
      else {
        cout<<n-1<<" "<<n<<"\n";
      }
     }
  }
  else{
       if(d==e){
         cout<<"1\n";
         if(b==d){
           cout<<"2 1\n";
         }
         else cout<<"1 2\n";
       }
       else {
          if(d==b){
            cout<<"2\n";
            cout<<"1 2\n"<<n-1<<" "<<n<<"\n";
          }
          else {
              cout<<"2\n";
              cout<<"2 1\n"<<n-1<<" "<<n<<"\n";
          }
       }
     }
  


 
 




 
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
   cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}