#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int q = 0; q < t; q++) {
    int n;
    cin >> n;
    char a[n][n];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> a[i][j];
    if (a[1][2] == a[2][1]) {
      if (a[1][2] == '1') {
        if (a[n - 1][n] == '0' && a[n][n - 1] == '0')
          cout << "0" << endl;
        else if (a[n - 1][n] == '1' && a[n][n - 1] == '1') {
          cout << "2" << endl;
          cout << n - 1 << " " << n << endl;
          cout << n << " " << n - 1 << endl;
        } else if (a[n - 1][n] == '1' && a[n][n - 1] == '0') {
          cout << "1" << endl;
          cout << n - 1 << " " << n << endl;
        } else if (a[n - 1][n] == '0' && a[n][n - 1] == '1') {
          cout << "2" << endl;
          cout << n << " " << n - 1 << endl;
        }
      } else {
        if (a[n - 1][n] == '1' && a[n][n - 1] == '1')
          cout << "0" << endl;
        else if (a[n - 1][n] == '0' && a[n][n - 1] == '0') {
          cout << "2" << endl;
          cout << n - 1 << " " << n << endl;
          cout << n << " " << n - 1 << endl;
        } else if (a[n - 1][n] == '0' && a[n][n - 1] == '1') {
          cout << "1" << endl;
          cout << n - 1 << " " << n << endl;
        } else if (a[n - 1][n] == '1' && a[n][n - 1] == '0') {
          cout << "1" << endl;
          cout << n << " " << n - 1 << endl;
        }
      }
    } else if (a[1][2] == '1' && a[2][1] == '0') {
      if (a[n - 1][n] == '0' && a[n][n - 1] == '0') {
        cout << "1" << endl;
        cout << "2 1";
      } else if (a[n - 1][n] == '1' && a[n][n - 1] == '1') {
        cout << "1" << endl;
        cout << "1 2" << endl;
      } else if (a[n - 1][n] == '1' && a[n][n - 1] == '0') {
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << n << " " << n - 1;
      } else if (a[n - 1][n] == '0' && a[n][n - 1] == '1') {
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << n - 1 << " " << n << endl;
      }
    } else if (a[1][2] == '0' && a[2][1] == '1') {
      if (a[n - 1][n] == '0' && a[n][n - 1] == '0') {
        cout << "1" << endl;
        cout << "1 2";
      } else if (a[n - 1][n] == '1' && a[n][n - 1] == '1') {
        cout << "1" << endl;
        cout << "2 1" << endl;
      } else if (a[n - 1][n] == '1' && a[n][n - 1] == '0') {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n << " " << n - 1;
      } else if (a[n - 1][n] == '0' && a[n][n - 1] == '1') {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n - 1 << " " << n << endl;
      }
    }
  }
}
