#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int>> res1, res2, res3;
void code2(long long int x, long long int y) {
  res1.push_back({x + 1, y + 1});
  res2.push_back({x + 1, y + 2});
  res3.push_back({x, y + 1});
  res1.push_back({x + 1, y + 1});
  res2.push_back({x + 1, y + 2});
  res3.push_back({x, y + 2});
  res1.push_back({x + 1, y + 1});
  res2.push_back({x, y + 2});
  res3.push_back({x, y + 1});
  return;
}
void code1(long long int x, long long int y) {
  res1.push_back({x, y});
  res2.push_back({x, y + 1});
  res3.push_back({x + 1, y});
  res1.push_back({x, y});
  res2.push_back({x, y + 1});
  res3.push_back({x + 1, y + 1});
  res1.push_back({x, y});
  res2.push_back({x + 1, y + 1});
  res3.push_back({x + 1, y});
  return;
}
void solve(long long int x, long long int y, long long int m, long long int n) {
  if (y < m - 1) {
    if (x < n - 1)
      code1(x + 1, y + 1);
    else
      code2(x, y);
  } else {
    if (x < n - 1) {
      res1.push_back({x + 1, y + 1});
      res2.push_back({x + 1, y});
      res3.push_back({x + 2, y + 1});
      res1.push_back({x + 1, y + 1});
      res2.push_back({x + 1, y});
      res3.push_back({x + 2, y});
      res1.push_back({x + 1, y + 1});
      res2.push_back({x + 2, y + 1});
      res3.push_back({x + 2, y});
    } else {
      res1.push_back({x + 1, y + 1});
      res2.push_back({x + 1, y});
      res3.push_back({x, y + 1});
      res1.push_back({x + 1, y + 1});
      res2.push_back({x + 1, y});
      res3.push_back({x, y});
      res1.push_back({x + 1, y + 1});
      res2.push_back({x, y + 1});
      res3.push_back({x, y});
    }
  }
  return;
}
int main() {
  long long int tc;
  cin >> tc;
  while (tc--) {
    long long int n, m;
    cin >> n >> m;
    vector<string> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (vec[i][j] == '1') {
          solve(i, j, m, n);
        }
      }
    }
    cout << res1.size() << endl;
    for (int i = 0; i < res1.size(); i++)
      cout << res1[i].first << " " << res1[i].second << " " << res2[i].first
           << " " << res2[i].second << " " << res3[i].first << " "
           << res3[i].second << endl;
    res1.clear();
    res2.clear();
    res3.clear();
  }
}
