#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define mk make_pair
#define pb push_back
#define int long long
#define sz(s) s.size()
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
const int N = 5e5+12,INF = 1e15+7,mod = 1e9+7;
int n,m,k,s,f,c,x,y,z,o,l,r,mx=0,mn=INF,ok,ans;
bool iswowel(char n){ n = toupper(n); if(n == 'A' || n == 'O' || n == 'U' || n == 'E' || n == 'I' || n == 'Y') return true; else return false;}
double e_dist(int x,int y,int xx,int yy){double a = (x-xx)*(x-xx);double b = (y-yy)*(y-yy);return(sqrt(a+b));}
int    m_dist(int x,int y,int xx,int yy){return (abs(x-xx)+abs(y-yy));}
int a[N],b[N],dp[N],used[N],dis[N],lp[N];
vector<int>g[N],pr[N];
string p,pp;

void dfs(int v,int d){
	used[v] = 1;
	for(int to : g[v])
		if(!used[to])
			dfs(to,d+1);
}

main(){

    cin>>o;
    while(o--){
    	cin>>n;
    	m = n;
    	int arr[n+1][n+1];
    	memset(arr,0,sizeof(arr));
    	
    	for(int i=1; i<=n; i++){
    		cin>>p;
    		for(int j=0; j<n; j++){
    			arr[i][j+1] = (p[j] == '1' ? 1 : 0);
			}
		}
		if(arr[1][2] == 1 && arr[2][1] == 0 && arr[n-1][m] == 0 && arr[n][m-1] == 0){//1
			cout<<1<<endl;
			cout<<2<<" "<<1<<endl;
		}
		else if(arr[1][2] == 0 && arr[2][1] == 1 && arr[n-1][m] == 0 && arr[n][m-1] == 0){//1
			cout<<2<<endl;
			cout<<1<<" "<<2<<endl;
		}
		else if(arr[1][2] == 0 && arr[2][1] == 0 && arr[n-1][m] == 1 && arr[n][m-1] == 0){//1
			cout<<2<<endl;
			cout<<m<<" "<<n-1<<endl;
		}
		else if(arr[1][2] == 0 && arr[2][1] == 0 && arr[n-1][m] == 0 && arr[n][m-1] == 1){//1
			cout<<1<<endl;
			cout<<n-1<<" "<<m<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 1 && arr[n-1][m] == 0 && arr[n][m-1] == 0){//2
			cout<<0<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 0 && arr[n-1][m] == 1 && arr[n][m-1] == 0){//3
			cout<<0<<endl;cout<<1<<endl;
			cout<<2<<" "<<1<<endl<<n-1<<" "<<m<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 0 && arr[n-1][m] == 0 && arr[n][m-1] == 1){//3
			cout<<1<<endl;
			cout<<1<<" "<<2<<endl<<" "<<n-1<<" "<<m<<endl;
		}
		else if(arr[1][2] == 0 && arr[2][1] == 1 && arr[n-1][m] == 1 && arr[n][m-1] == 0){//4
			cout<<2<<endl;
			cout<<1<<" "<<2<<endl<<n-1<<" "<<m<<endl;
		}
	    else if(arr[1][2] == 0 && arr[2][1] == 0 && arr[n-1][m] == 1 && arr[n][m-1] == 1){//5
			cout<<0<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 1 && arr[n-1][m] == 1 && arr[n][m-1] == 0){//6
			cout<<n-1<<" "<<m<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 1 && arr[n-1][m] == 0 && arr[n][m-1] == 1){//7
			cout<<1<<endl;
			cout<<n<<" "<<m-1<<endl;
		}
		else if(arr[1][2] == 0 && arr[2][1] == 1 && arr[n-1][m] == 1 && arr[n][m-1] == 1){//7
			cout<<1<<endl;
			cout<<2<<" "<<1<<endl;
		}
		else if(arr[1][2] == 1 && arr[2][1] == 1 && arr[n-1][m] == 1 && arr[n][m-1] == 1){//8
			cout<<2<<endl;
			cout<<1<<" "<<2<<endl<<2<<" "<<1<<endl;		
		}
		else if(arr[1][2] == 0 && arr[2][1] == 1 && arr[n-1][m] == 0 && arr[n][m-1] == 1){//5
			cout<<1<<endl;
		
			cout<<1<<" "<<2<<endl<<n<<" "<<m-1<<endl;
		}
	}
    

}
