#include <bits/stdc++.h>
using namespace std;
int a[105][105];
struct second {
  int x, y, z, i, j, k;
  void pr() {
    cout << x + 1 << " " << y + 1 << " " << z + 1 << " " << i + 1 << " "
         << j + 1 << " " << k + 1 << "\n";
  }
};
void tc() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) {
    string s;
    cin >> s;
    for (int j = 0; j < int(m); j++) {
      a[i][j] = s[j] - '0';
    }
  }
  vector<second> ans;
  for (int i = 0; i < int(n - 1); i++)
    for (int j = 0; j < int(m - 1); j++) {
      int cnt = 0;
      do {
        cnt = 0;
        for (int x : {i, i + 1}) {
          for (int y : {j, j + 1}) {
            if (a[x][y]) {
              ++cnt;
            }
          }
        }
        if (cnt == 1 || cnt == 2) {
          int r = -1, c = -1;
          for (int x : {i, i + 1}) {
            for (int y : {j, j + 1}) {
              if (a[x][y]) {
                r = x, c = y;
              }
            }
          }
          int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
          if (r == i) {
            x1 = i + 1, y1 = c;
          } else {
            x1 = i, y1 = c;
          }
          if (c == j) {
            x2 = r, y2 = c + 1;
          } else {
            x2 = r, y2 = j;
          }
          ans.push_back(second{r, c, x1, y1, x2, y2});
          a[r][c] ^= 1;
          a[x1][y1] ^= 1;
          a[x2][y2] ^= 1;
        } else if (cnt == 3) {
          int r = -1, c = -1, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
          for (int x : {i, i + 1}) {
            for (int y : {j, j + 1}) {
              if (a[x][y]) {
                if (r == -1) {
                  r = x, c = y;
                } else if (x1 == -1) {
                  x1 = x, y1 = y;
                } else {
                  x2 = x, y2 = y;
                }
              }
            }
          }
          ans.push_back(second{r, c, x1, y1, x2, y2});
          a[r][c] = a[x1][y1] = a[x2][y2] = 0;
        } else if (cnt == 4) {
          ans.push_back(second{i, j, i + 1, j, i, j + 1});
          a[i][j] = a[i + 1][j] = a[i][j + 1] = 0;
        }
      } while (cnt != 0);
    }
  cout << ans.size() << "\n";
  for (auto& s : ans) {
    s.pr();
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    tc();
  }
}
