#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, 1};
int dy[] = {0, 0, 1, 1};
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> v;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      v.push_back(s);
    }
    vector<pair<int, int> > ans;
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m - 1; j++) {
        int cnt = 0;
        cnt += v[i][j] - '0';
        cnt += v[i + 1][j] - '0';
        cnt += v[i][j + 1] - '0';
        cnt += v[i + 1][j + 1] - '0';
        if (cnt == 3) {
          for (int k = 0; k < 4; k++) {
            int sx = i + dx[k];
            int sy = j + dy[k];
            if (v[sx][sy] == '1') {
              ans.push_back({sx, sy});
              v[sx][sy] = '0';
            }
          }
        }
        if (cnt == 1) {
          if (v[i][j] == '1' || i == n - 2 || j == m - 2) {
            int lol = 2;
            for (int k = 0; k < 4; k++) {
              int sx = i + dx[k];
              int sy = j + dy[k];
              if (v[sx][sy] == '1') {
                ans.push_back({sx, sy});
                v[sx][sy] = '0';
              } else if (lol) {
                ans.push_back({sx, sy});
                v[sx][sy] = '1';
                lol--;
              }
            }
            j--;
          }
        }
        if (cnt == 2) {
          if (v[i][j] == '1' || i == n - 2 || j == m - 2) {
            int lol = 1;
            for (int k = 0; k < 4; k++) {
              int sx = i + dx[k];
              int sy = j + dy[k];
              if (v[sx][sy] == '0') {
                ans.push_back({sx, sy});
                v[sx][sy] = '1';
              } else if (lol) {
                ans.push_back({sx, sy});
                v[sx][sy] = '0';
                lol--;
              }
            }
            j--;
          }
        }
        if (cnt == 4) {
          int lol = 3;
          for (int k = 0; k < 4; k++) {
            int sx = i + dx[k];
            int sy = j + dy[k];
            if (v[sx][sy] == '1' && lol) {
              ans.push_back({sx, sy});
              v[sx][sy] = '0';
              lol--;
            }
          }
          j--;
        }
      }
    }
    cout << ans.size() / 3 << '\n';
    for (int i = 0; i < ans.size(); i += 3) {
      cout << ans[i].first + 1 << " " << ans[i].second + 1 << " "
           << ans[i + 1].first + 1 << " " << ans[i + 1].second + 1 << " "
           << ans[i + 2].first + 1 << " " << ans[i + 2].second + 1 << '\n';
    }
  }
  return 0;
}
