#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int main(){
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<string> grid(n);
        for(int i=0; i<n; i++){
            string s;
            cin>>s;
            grid[i] = s;
        }
        char a = grid[0][1], b = grid[1][0];
        char x = grid[n-1][n-2], y = grid[n-2][n-1];
        vector<vector<int> > ans;
        if(a==b){
            if(a==x){
                ans.push_back(vector<int>{n-1, n-2});
                grid[n-1][n-2] = a == '1' ? '0' : '1';
            }
            if(a == y){
                ans.push_back(vector<int>{n-2, n-1});
                grid[n-2][n-1] = a == '1' ? '0' : '1';
            }
        }
        else if(x == y){
            if(x==a){
                ans.push_back(vector<int>{0,1});
                grid[0][1] = x == '1' ? '0' : '1';
            }
            if(x == b){
                ans.push_back(vector<int>{1,0});
                grid[1][0] = x == '1' ? '0' : '1';
            }
        }
        else{
            ans.push_back(vector<int>(1,0));
            ans.push_back(vector<int>{n-2, n-1});
            grid[1][0] = a == '1' ? '1' : '0';
            grid[n-2][n-1] = x == '1' ? '1' : '2';
        }
        cout<<ans.size()<<endl;;
        for(auto v : ans){
            cout<<v[0]+1<<" "<<v[1]+1<<endl;
        }


    }
 }
