#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char ch[n + 2][n + 2];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> ch[i][j];
      }
    }
    vector<int> v;
    int ans = 0;
    if (ch[1][2] == '0' && ch[2][1] == '0') {
      if (ch[n][n - 1] == '0' && ch[n - 1][n] == '0') {
        ans = 2;
        v.push_back(n - 1);
        v.push_back(n);
        v.push_back(n);
        v.push_back(n - 1);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '1') {
        ans = 0;
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '0') {
        ans = 1;
        v.push_back(n - 1);
        v.push_back(n);
      } else if (ch[n][n - 1] == '0' && ch[n - 1][n] == '1') {
        ans = 1;
        v.push_back(n);
        v.push_back(n - 1);
      }
    } else if (ch[1][2] == '1' && ch[2][1] == '1') {
      if (ch[n][n - 1] == '0' && ch[n - 1][n] == '0') {
        ans = 0;
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '1') {
        ans = 2;
        v.push_back(n - 1);
        v.push_back(n);
        v.push_back(n);
        v.push_back(n - 1);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '0') {
        ans = 1;
        v.push_back(n);
        v.push_back(n - 1);
      } else if (ch[n][n - 1] == '0' && ch[n - 1][n] == '1') {
        ans = 1;
        v.push_back(n - 1);
        v.push_back(n);
      }
    } else if (ch[1][2] == '1' && ch[2][1] == '0') {
      if (ch[n][n - 1] == '0' && ch[n - 1][n] == '0') {
        ans = 1;
        v.push_back(1);
        v.push_back(2);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '1') {
        ans = 1;
        v.push_back(2);
        v.push_back(1);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '0') {
        ans = 2;
        v.push_back(1);
        v.push_back(2);
        v.push_back(n);
        v.push_back(n - 1);
      } else if (ch[n][n - 1] == '0' && ch[n - 1][n] == '1') {
        ans = 2;
        v.push_back(2);
        v.push_back(1);
        v.push_back(n);
        v.push_back(n - 1);
      }
    } else if (ch[1][2] == '0' && ch[2][1] == '1') {
      if (ch[n][n - 1] == '0' && ch[n - 1][n] == '0') {
        ans = 1;
        v.push_back(2);
        v.push_back(1);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '1') {
        ans = 1;
        v.push_back(1);
        v.push_back(2);
      } else if (ch[n][n - 1] == '1' && ch[n - 1][n] == '0') {
        ans = 2;
        v.push_back(2);
        v.push_back(1);
        v.push_back(n);
        v.push_back(n - 1);
      } else if (ch[n][n - 1] == '0' && ch[n - 1][n] == '1') {
        ans = 2;
        v.push_back(1);
        v.push_back(2);
        v.push_back(n);
        v.push_back(n - 1);
      }
    }
    cout << ans << endl;
    for (int i = 0; i < ans * 2; i++) {
      cout << v[i] << ' ';
      if (i == 1 || i == 3) cout << endl;
    }
  }
}
