#include <bits/stdc++.h>
using namespace std;
string numtostr(long long n) {
  ostringstream str1;
  str1 << n;
  return str1.str();
}
long long strtonum(string s) {
  long long x;
  stringstream str1(s);
  str1 >> x;
  return x;
}
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
  long long gcd = GCD(a, b);
  return (a / gcd) * b;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    n--;
    vector<string> v(n + 5);
    for (long long i = 0; i <= n; i++) {
      string s;
      cin >> s;
      v[i] = s;
    }
    vector<pair<pair<long long, long long>, long long> > vitor, bahire;
    long long x = (v[n][n - 1] - '0');
    vitor.push_back({{n, n - 1}, x});
    x = (v[n - 1][n] - '0');
    vitor.push_back({{n - 1, n}, x});
    x = (v[n][n - 2] - '0');
    bahire.push_back({{n, n - 2}, x});
    x = (v[n - 2][n] - '0');
    bahire.push_back({{n - 2, n}, x});
    x = (v[n - 1][n - 1] - '0');
    bahire.push_back({{n - 1, n - 1}, x});
    long long vitorone = 0;
    long long bahirone = 0;
    for (long long i = 0; i <= vitor.size() - 1; i++) {
      if (vitor[i].second == 1) vitorone++;
    }
    for (long long i = 0; i <= bahire.size() - 1; i++) {
      if (bahire[i].second == 1) bahirone++;
    }
    vector<pair<long long, long long> > result;
    if (bahirone == 0) {
      if (vitorone == 1) {
        for (long long i = 0; i <= vitor.size() - 1; i++) {
          if (vitor[i].second == 0) {
            result.push_back({vitor[i].first.first, vitor[i].first.second});
          }
        }
      } else if (vitorone == 0) {
        for (long long i = 0; i <= vitor.size() - 1; i++) {
          if (vitor[i].second == 0) {
            result.push_back({vitor[i].first.first, vitor[i].first.second});
          }
        }
      }
    } else if (bahirone == 1) {
      if (vitorone == 0) {
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 0) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
      } else if (vitorone == 1) {
        for (long long i = 0; i <= vitor.size() - 1; i++) {
          if (vitor[i].second == 0) {
            result.push_back({vitor[i].first.first, vitor[i].first.second});
          }
        }
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 1) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
      } else {
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 1) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
      }
    } else if (bahirone == 2) {
      if (vitorone == 0) {
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 0) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
      } else if (vitorone == 1) {
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 0) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
        for (long long i = 0; i <= vitor.size() - 1; i++) {
          if (vitor[i].second == 1) {
            result.push_back({vitor[i].first.first, vitor[i].first.second});
          }
        }
      } else if (vitorone == 2) {
        for (long long i = 0; i <= bahire.size() - 1; i++) {
          if (bahire[i].second == 1) {
            result.push_back({bahire[i].first.first, bahire[i].first.second});
          }
        }
      }
    } else if (bahirone == 3) {
      for (long long i = 0; i <= vitor.size() - 1; i++) {
        if (vitor[i].second == 0) {
          result.push_back({vitor[i].first.first, vitor[i].first.second});
        }
      }
    }
    cout << result.size() << endl;
    if (result.size())
      for (long long i = 0; i <= result.size() - 1; i++)
        cout << result[i].first + 1 << " " << result[i].second + 1 << endl;
  }
  return 0;
}
