#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> par;
typedef vector<par> parv;
typedef vector<vi> vvi;
// Author : Koushal Bhat
#define forr(i,p,n) for( ll i=p; i<n; i++)
#define forn(i,p,n) for(ll i=p; i<=n; i++)
#define rev(i,n,p) for(ll i=n; i>=p; i--)
#define PI 3.14159265358979323846
#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() {
    ll n=0;
    cin>>n;
    char mat[n][n]={0};
    forr(i,0,n)
    {
        forr(j,0,n)
        {
            cin>>mat[i][j];
        }
    }
    ll one=mat[0][1]-'0';
    ll two=mat[1][0]-'0';
    ll four=mat[n-1][n-2]-'0';
    ll three=mat[n-2][n-1]-'0';
    //cout<<one<<" "<<two<<" "<<three<<" "<<four<<'\n';
    if(one==two)
    {
        if(one==1)
        {
            if(three==1 && four==1)
            {
                cout<<"2\n";
                cout<<n<<" "<<n-1<<'\n';
                cout<<n-1<<" "<<n<<'\n';
            }
            else if(three==1 && four==0)
            {
                cout<<"1\n";
                cout<<n-1<<" "<<n<<'\n';
            }
            else if(three==0 && four==1)
            {
                cout<<"1\n";
                cout<<n<<" "<<n-1<<'\n';
            }
            else
            {
                cout<<"0\n";
            }
            
        }
        else if(one==0)
        {
            if(three==0 && four==0)
            {
                cout<<"2\n";
                cout<<n<<" "<<n-1<<'\n';
                cout<<n-1<<" "<<n<<'\n';
            }
            else if(three==0 && four==1)
            {
                cout<<"1\n";
                cout<<n-1<<" "<<n<<'\n';
            }
            else if(three==1 && four==0)
            {
                cout<<"1\n";
                cout<<n<<" "<<n-1<<'\n';
            }
            else
            {
                cout<<"0\n";
            }
        }
    }
    else if(three==four)
    {
        if(three==1)
        {
            if(one==1 && two==1)
            {
                cout<<"2\n";
                cout<<"1"<<" "<<"2"<<'\n';
                cout<<"2"<<" "<<"1"<<'\n';
            }
            else if(one==1 && two==0)
            {
                cout<<"1\n";
                cout<<"1"<<" "<<"2"<<'\n';
            }
            else if(one==0 && two==1)
            {
                cout<<"1\n";
                cout<<"2"<<" "<<"1"<<'\n';
            }
            else
            {
                cout<<"0\n";
            }
            
        }
        else if(three==0)
        { 
           if(one==0 && two==0)
            {
                cout<<"2\n";
                cout<<"1"<<" "<<"2"<<'\n';
                cout<<"2"<<" "<<"1"<<'\n';
            }
            else if(one==0 && two==1)
            {
                cout<<"1\n";
                cout<<"1"<<" "<<"2"<<'\n';
            }
            else if(one==1 && two==0)
            {
                cout<<"1\n";
                cout<<"2"<<" "<<"1"<<'\n';
            }
            else
            {
                cout<<"0\n";
            }
        }
    }

    else
    {
        cout<<"2\n";
        cout<<"1 2\n";
        cout<<n<<" "<<n-1<<'\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll tc; cin >> tc;
    forn(t,1,tc) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}