#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
vector<pair<long long, long long>> toprint;
void convert(vector<string> &a, long long x1, long long y1, long long x2,
             long long y2, long long x3, long long y3, long long x4,
             long long y4) {
  vector<pair<long long, long long>> o, z;
  vector<pair<long long, long long>> x;
  x.push_back({x1, y1});
  x.push_back({x2, y2});
  x.push_back({x3, y3});
  x.push_back({x4, y4});
  for (pair<long long, long long> p : x) {
    if (a[p.first][p.second] == '0') {
      z.push_back(p);
    } else {
      o.push_back(p);
    }
  }
  if (z.size() == 4) return;
  if (z.size() == 3) {
    toprint.push_back(o.back());
    a[o.back().first][o.back().second] = '0';
    z.push_back(o.back());
    o.pop_back();
    long long cnt = 0;
    for (auto p : z) {
      cnt++;
      if (cnt > 2) break;
      toprint.push_back(p);
      a[p.first][p.second] = '1';
      o.push_back(p);
    }
    z.erase(z.begin());
    z.erase(z.begin());
    toprint.push_back(o.back());
    a[o.back().first][o.back().second] = '0';
    z.push_back(o.back());
    o.pop_back();
    cnt = 0;
    for (auto p : z) {
      cnt++;
      if (cnt > 2) break;
      toprint.push_back(p);
      a[p.first][p.second] = '1';
      o.push_back(p);
    }
    z.erase(z.begin());
    z.erase(z.begin());
    for (auto p : o) {
      toprint.push_back(p);
      a[p.first][p.second] = '0';
      z.push_back(p);
    }
    o.clear();
  } else if (z.size() == 2) {
    toprint.push_back(o.back());
    a[o.back().first][o.back().second] = '0';
    z.push_back(o.back());
    o.pop_back();
    long long cnt = 0;
    for (auto p : z) {
      cnt++;
      if (cnt > 2) break;
      toprint.push_back(p);
      a[p.first][p.second] = '1';
      o.push_back(p);
    }
    z.erase(z.begin());
    z.erase(z.begin());
    for (auto p : o) {
      toprint.push_back(p);
      a[p.first][p.second] = '0';
      z.push_back(p);
    }
    o.clear();
  } else if (z.size() == 1) {
    for (auto p : o) {
      toprint.push_back(p);
      a[p.first][p.second] = '0';
      z.push_back(p);
    }
    o.clear();
  } else if (z.size() == 0) {
    long long cnt = 0;
    for (auto p : o) {
      cnt++;
      if (cnt > 3) break;
      toprint.push_back(p);
      a[p.first][p.second] = '0';
      z.push_back(p);
    }
    o.erase(o.begin());
    o.erase(o.begin());
    o.erase(o.begin());
    toprint.push_back(o.back());
    a[o.back().first][o.back().second] = '0';
    z.push_back(o.back());
    o.pop_back();
    cnt = 0;
    for (auto p : z) {
      cnt++;
      if (cnt > 2) break;
      toprint.push_back(p);
      a[p.first][p.second] = '1';
      o.push_back(p);
    }
    z.erase(z.begin());
    z.erase(z.begin());
    toprint.push_back(o.back());
    a[o.back().first][o.back().second] = '0';
    z.push_back(o.back());
    o.pop_back();
    cnt = 0;
    for (auto p : z) {
      cnt++;
      if (cnt > 2) break;
      toprint.push_back(p);
      a[p.first][p.second] = '1';
      o.push_back(p);
    }
    z.erase(z.begin());
    z.erase(z.begin());
    for (auto p : o) {
      toprint.push_back(p);
      a[p.first][p.second] = '0';
      z.push_back(p);
    }
    o.clear();
  }
}
void solve() {
  toprint.clear();
  long long n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i + 1 < n; i++) {
    for (long long j = 0; j + 1 < m; j++) {
      convert(a, i, j, i + 1, j, i, j + 1, i + 1, j + 1);
    }
  }
  cout << toprint.size() / 3 << '\n';
  for (long long i = 0; i < toprint.size(); i += 3) {
    cout << toprint[i].first + 1 << ' ' << toprint[i].second + 1 << ' '
         << toprint[i + 1].first + 1 << ' ' << toprint[i + 1].second + 1 << ' '
         << toprint[i + 2].first + 1 << ' ' << toprint[i + 2].second + 1
         << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
}
