#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int 
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define M 998244353
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
const int inf=1e9;
bool isprime(int n)
	{
    	if(n==1) return false;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 

int power(int x, unsigned int y,int p)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1){
        	res*=x;
        	res%=p;
		}   
        y = y>>1;  
        x = (x*x); 
		x%=p;
		res%=p; 
    }  
    return res;  
}
int modInverse(int n, int p){
    return power(n, p-2,p);
}
// Returns nCr % p using Fermat's little theorem.
int ncrmodp(int n, int r, int p){
   // Base case
   if (r==0)
      return 1;
    else if(n<r)
        return 0;
    else{
        // Fill factorial array so that we can find all factorial of r, n and n-r
        int fac[n+1];
        fac[0] = 1;
        for (int i=1 ; i<=n; i++)
            fac[i] = (fac[i-1]*i)%p;
 
        return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p;
    }
}
struct node{
	int x,y;
};
deque<int>dq;
signed main(){
	FAST
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<string>v;
		int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			if(i==0){
				if(s[1]=='1')a++;
				else b++;
			}
			if(i==1){
				if(s[0]=='1')c++;
				else d++;
			}
			if(i==n-2){
				if(s[n-1]=='1')e++;
				else f++;
			}
			if(i==n-1){
				if(s[n-2]=='1')g++;
				else h++;
			}
		}
		vector<pair<int,int>>vp;
		if(a==0 && c==0){
			if(e==0){
				vp.push_back({n-1,n});
			}
			if(g==0){
				vp.push_back({n,n-1});
			}
		}
		else if(a==0 && c==1){
			if(e==g){
				if(e==1){
					vp.push_back({2,1});
				}
				else{
					vp.push_back({1,2});
				}
			}
			else{
				vp.push_back({1,2});
				if(e==1)vp.push_back({n-1,n});
				if(g==1)vp.push_back({n,n-1});
			}
		}
		else if(a==1 && c==0){
			if(e==g){
				if(e==1){
					vp.push_back({2,1});
				}
				else{
					vp.push_back({1,2});
				}
			}
			else{
				vp.push_back({1,2});
				if(e==0)vp.push_back({n-1,n});
				if(g==0)vp.push_back({n,n-1});
			}
		}
		else {
			if(e==1){
				vp.push_back({n-1,n});
			}
			if(g==1){
				vp.push_back({n,n-1});
			}
		}
		cout<<vp.size()<<endl;
		for(auto &x:vp){
			cout<<x.first<<" "<<x.second<<endl;
		}
	}
}

