#include <bits/stdc++.h>
using namespace std;
vector<string> s;
vector<vector<pair<long long, long long>>> res;
void ck(long long x, long long y) {
  string temp = "";
  temp.push_back(s[x][y]);
  temp.push_back(s[x][y + 1]);
  temp.push_back(s[x + 1][y + 1]);
  temp.push_back(s[x + 1][y]);
  pair<long long, long long> arr[4];
  arr[0] = {x, y};
  arr[1] = {x, y + 1};
  arr[2] = {x + 1, y + 1};
  arr[3] = {x + 1, y};
  if (temp[0] + temp[1] + temp[2] + temp[3] - (4 * '0') == 4) {
    vector<pair<long long, long long>> foo;
    foo.push_back(arr[0]);
    foo.push_back(arr[1]);
    foo.push_back(arr[2]);
    temp[0] = '0';
    temp[1] = '0';
    temp[2] = '0';
    res.push_back(foo);
  }
  if (temp[0] + temp[1] + temp[2] + temp[3] - (4 * '0') == 1) {
    vector<pair<long long, long long>> foo;
    if (temp[0] == '1') {
      foo.push_back(arr[0]);
      foo.push_back(arr[1]);
      foo.push_back(arr[2]);
      temp[0] = '0';
      temp[1] = '1';
      temp[2] = '1';
    } else {
      foo.push_back(arr[3]);
      foo.push_back(arr[1]);
      foo.push_back(arr[2]);
      temp[3] = '1' - temp[3] + '0';
      temp[1] = '1' - temp[1] + '0';
      temp[2] = '1' - temp[2] + '0';
    }
    res.push_back(foo);
  }
  if (temp[0] + temp[1] + temp[2] + temp[3] - (4 * '0') == 2) {
    long long x = 0;
    for (; x < 4 && temp[x] == '0'; x++)
      ;
    vector<pair<long long, long long>> foo;
    foo.push_back(arr[(x + 1) % 4]);
    foo.push_back(arr[(x + 2) % 4]);
    foo.push_back(arr[(x + 3) % 4]);
    temp[(x + 1) % 4] = '1' - temp[(x + 1) % 4] + '0';
    temp[(x + 2) % 4] = '1' - temp[(x + 2) % 4] + '0';
    temp[(x + 3) % 4] = '1' - temp[(x + 3) % 4] + '0';
    res.push_back(foo);
  }
  if (temp[0] + temp[1] + temp[2] + temp[3] - (4 * '0') == 3) {
    long long x = 0;
    for (; x < 4 && temp[x] == '1'; x++)
      ;
    vector<pair<long long, long long>> foo;
    foo.push_back(arr[(x + 1) % 4]);
    foo.push_back(arr[(x + 2) % 4]);
    foo.push_back(arr[(x + 3) % 4]);
    temp[(x + 1) % 4] = '1' - temp[(x + 1) % 4] + '0';
    temp[(x + 2) % 4] = '1' - temp[(x + 2) % 4] + '0';
    temp[(x + 3) % 4] = '1' - temp[(x + 3) % 4] + '0';
    res.push_back(foo);
  }
  s[x][y] = s[x][y + 1] = s[x + 1][y + 1] = s[x + 1][y] = '0';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    s.clear();
    cin >> n >> m;
    s.resize(n);
    for (long long i = 0; i < n; i++) cin >> s[i];
    res.clear();
    for (long long i = 0; i + 1 < n; i += 2) {
      for (long long j = 0; j + 1 < m; j += 2) {
        ck(i, j);
      }
      if (m % 2) {
        ck(i, m - 2);
      }
    }
    if (n % 2) {
      for (long long j = 0; j + 1 < m; j += 2) {
        ck(n - 2, j);
      }
      if (m % 2) {
        ck(n - 2, m - 2);
      }
    }
    cout << res.size() << "\n";
    for (auto x : res) {
      for (auto y : x) {
        cout << y.first + 1 << " " << y.second + 1 << " ";
      }
      cout << "\n";
    }
  }
}
