#include <bits/stdc++.h>
using namespace std;
int n, m;
int grid[105][105];
vector<pair<int, int> > ans;
void apb(int aw, int bw) {
  ans.push_back(make_pair(aw + 1, bw + 1));
  grid[aw][bw] ^= 1;
}
void solve3(int r, int c) {
  for (int i = r; i <= r + 1; i++) {
    for (int j = c; j <= c + 1; j++) {
      if (grid[i][j] == 1) apb(i, j);
    }
  }
}
void solve2(int r, int c) {
  int saw = 0;
  for (int i = r; i <= r + 1; i++) {
    for (int j = c; j <= c + 1; j++) {
      if (grid[i][j] == 0) {
        apb(i, j);
      } else if (!saw) {
        apb(i, j);
        saw++;
      }
    }
  }
  solve3(r, c);
}
void solve1(int r, int c) {
  if (grid[r][c] == 1) {
    apb(r, c);
    apb(r + 1, c);
    apb(r + 1, c + 1);
  } else if (grid[r + 1][c] == 1) {
    apb(r + 1, c);
    apb(r, c);
    apb(r, c + 1);
  } else if (grid[r][c + 1] == 1) {
    apb(r, c + 1);
    apb(r, c);
    apb(r + 1, c);
  } else if (grid[r + 1][c + 1] == 1) {
    apb(r + 1, c + 1);
    apb(r, c);
    apb(r + 1, c);
  }
  solve2(r, c);
}
void solve4(int r, int c) {
  apb(r, c);
  apb(r + 1, c);
  apb(r, c + 1);
  solve1(r, c);
}
void zzero(int r, int c) {
  int ct = grid[r][c] + grid[r + 1][c] + grid[r][c + 1] + grid[r + 1][c + 1];
  if (ct == 1) solve1(r, c);
  if (ct == 2) solve2(r, c);
  if (ct == 3) solve3(r, c);
  if (ct == 4) solve4(r, c);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    ans.clear();
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        char c;
        cin >> c;
        if (c == '0')
          grid[i][j] = 0;
        else
          grid[i][j] = 1;
      }
    for (int i = 0; i < n; i += 2) {
      for (int j = 0; j < m; j += 2) {
        if (i == n - 1) i--;
        if (j == m - 1) j--;
        zzero(i, j);
      }
    }
    cout << ans.size() / 3 << '\n';
    for (int i = 0; i < ans.size(); i += 3) {
      cout << ans[i].first << ' ' << ans[i].second << ' ' << ans[i + 1].first
           << ' ' << ans[i + 1].second << ' ' << ans[i + 2].first << ' '
           << ans[i + 2].second << '\n';
    }
  }
}
