#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 200005;
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powb(long long a, long long b) {
  long long res = 1;
  a;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    a = a * a;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < m; j++) {
        a[i][j] = s[j] - '0';
      }
    }
    vector<vector<int>> ans;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (i + 1 < n && j + 1 < m) {
          while (1) {
            int ct = 0;
            ct += a[i][j] + a[i + 1][j] + a[i][j + 1] + a[i + 1][j + 1];
            vector<pair<int, int>> ones, zeroes;
            if (a[i][j])
              ones.push_back({i, j});
            else
              zeroes.push_back({i, j});
            if (a[i + 1][j])
              ones.push_back({i + 1, j});
            else
              zeroes.push_back({i + 1, j});
            if (a[i][j + 1])
              ones.push_back({i, j + 1});
            else
              zeroes.push_back({i, j + 1});
            if (a[i + 1][j + 1])
              ones.push_back({i + 1, j + 1});
            else
              zeroes.push_back({i + 1, j + 1});
            if (!ct) break;
            vector<int> change;
            switch (ct) {
              case 1:
                for (int k = 0; k < 1; k++) {
                  int x = ones[k].first, y = ones[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                for (int k = 0; k < 2; k++) {
                  int x = zeroes[k].first, y = zeroes[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                break;
              case 2:
                for (int k = 0; k < 1; k++) {
                  int x = ones[k].first, y = ones[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                for (int k = 0; k < 2; k++) {
                  int x = zeroes[k].first, y = zeroes[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                break;
              case 3:
                for (int k = 0; k < 3; k++) {
                  int x = ones[k].first, y = ones[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                break;
              case 4:
                for (int k = 0; k < 3; k++) {
                  int x = ones[k].first, y = ones[k].second;
                  change.push_back(x);
                  change.push_back(y);
                  a[x][y] ^= 1;
                }
                break;
            }
            ans.push_back(change);
          }
        }
      }
    }
    assert(ans.size() <= 3 * n * m);
    cout << (int)(ans.size()) << "\n";
    for (auto i : ans) {
      for (auto j : i) cout << j + 1 << " ";
      cout << "\n";
    }
  }
}
