#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector< pii >
#define vpll vector< pll >
#define mpii map<int,int>
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll pow(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}
pll dir[]={{1,0},{-1,0},{0,1},{0,-1}};
bool valid(int x,int y,int n,int m)
{
    if(x>=0 and x<n and y>=0 and y<m)return true;
    return false;
}
bool bfs(vector<char> g[],int n,int m,char c,int a,int b)
{
    if(!valid(a,b,n,m))return false;
    vector<vector<bool>> vis(n,vector<bool>(m,0));
    queue<pll> q;
    q.push({1,1});
    vis[1][1]=1;
    while(!q.empty())
    {
        pll x=q.front();
        q.pop();
        FOR(i,0,3)
        {
            int xx=x.f+dir[i].f,yy=x.sc+dir[i].sc;
            if(valid(xx,yy,n,m) and !vis[xx][yy] and g[xx][yy]==c)
            {
                q.push({xx,yy});
                vis[xx][yy]=1;
            }
        }
    }
    if(vis[a][b])return 1;
    return 0;
}

int main()
{
    test
    {
        int n,m;
        cin>>n;m=n;
        vector<char> a[n];
        FOR(i,0,n-1)
        {
            string s;
            cin>>s;
            FOR(j,0,m-1)
            a[i].pb(s[j]);
        }
        vpll v;

       if(a[0][1]=='0' and a[1][0]=='0')
       {
           if(a[n-1][m-2]=='0' and a[n-2][m-1]=='0')
           {
               v.eb(n-1,m-2);v.eb(n-2,m-1);
           }
           else if(a[n-1][m-2]=='0')
           {
               v.eb(n-1,m-2);
           }
           else if(a[n-2][m-1]=='0')
           {
               v.eb(n-2,m-1);
           }
       }
       else if(a[0][1]=='1' and a[1][0]=='1')
       {
           if(a[n-1][m-2]=='1' and a[n-2][m-1]=='1')
           {
               v.eb(n-1,m-2);v.eb(n-2,m-1);
           }
           else if(a[n-1][m-2]=='1')
           {
               v.eb(n-1,m-2);
           }
           else if(a[n-2][m-1]=='1')
           {
               v.eb(n-2,m-1);
           }
       }
       else if(a[0][1]=='1' and a[1][0]=='0')
       {
           if(a[n-1][m-2]=='0' and a[n-2][m-1]=='0')
           {
               v.eb(1,0);
           }
           else if(a[n-1][m-2]=='1' and a[n-2][m-1]=='1')
           {
               v.eb(0,1);
           }
           else if(a[n-1][m-2]=='0')
           {
               v.eb(n-1,m-2);v.eb(0,1);
           }
           else if(a[n-2][m-1]=='0')
           {
               v.eb(n-2,m-1);v.eb(0,1);
           }
       }
       else if(a[0][1]=='0' and a[1][0]=='1')
       {
           if(a[n-1][m-2]=='0' and a[n-2][m-1]=='0')
           {
               v.eb(0,1);
           }
           else if(a[n-1][m-2]=='1' and a[n-2][m-1]=='1')
           {
               v.eb(1,0);
           }
           else if(a[n-1][m-2]=='0')
           {
               v.eb(n-1,m-2);v.eb(1,0);
           }
           else if(a[n-2][m-1]=='0')
           {
               v.eb(n-2,m-1);v.eb(1,0);
           }
       }
       cout<<s(v)<<nl;
       trav(it,v)
       cout<<it.f<<' '<<it.sc<<nl;

    }
}
