#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    string s[n], s1[n];
    for (long long i = 0; i < n; i++) {
      cin >> s[i];
      s1[i] = s[i];
    }
    long long cnt = 0;
    for (long long i = 0; i < n - 1; i++) {
      for (long long j = 0; j < m - 1; j++) {
        vector<pair<long long, long long> > arr1;
        vector<pair<long long, long long> > arr0;
        for (long long i1 = 0; i1 < 2; i1++) {
          for (long long j1 = 0; j1 < 2; j1++) {
            if (s1[i + i1][j + j1] == '1') {
              arr1.push_back(make_pair(i + i1, j + j1));
            } else {
              arr0.push_back(make_pair(i + i1, j + j1));
            }
            s1[i + i1][j + j1] = '0';
          }
        }
        if (arr1.size() == 3) {
          cnt += 1;
        } else if (arr1.size() == 1) {
          cnt += 3;
        } else if (arr1.size() == 2) {
          cnt += 2;
        } else if (arr1.size() == 4) {
          cnt += 4;
        }
        if (j < m - 3) {
          j++;
        }
      }
      if (i < n - 3) {
        i++;
      }
    }
    cout << cnt << endl;
    for (long long i = 0; i < n - 1; i++) {
      for (long long j = 0; j < m - 1; j++) {
        vector<pair<long long, long long> > arr1;
        vector<pair<long long, long long> > arr0;
        for (long long i1 = 0; i1 < 2; i1++) {
          for (long long j1 = 0; j1 < 2; j1++) {
            if (s[i + i1][j + j1] == '1') {
              arr1.push_back(make_pair(i + i1 + 1, j + j1 + 1));
            } else {
              arr0.push_back(make_pair(i + i1 + 1, j + j1 + 1));
            }
            s[i + i1][j + j1] = '0';
          }
        }
        if (arr1.size() == 3) {
          for (long long i1 = 0; i1 < arr1.size(); i1++) {
            cout << arr1[i1].first << " " << arr1[i1].second << " ";
          }
          cout << endl;
        } else if (arr1.size() == 1) {
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr0[0].first << " " << arr0[0].second << " ";
          cout << arr0[1].first << " " << arr0[1].second << " ";
          cout << endl;
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr0[0].first << " " << arr0[0].second << " ";
          cout << arr0[2].first << " " << arr0[2].second << " ";
          cout << endl;
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr0[1].first << " " << arr0[1].second << " ";
          cout << arr0[2].first << " " << arr0[2].second << " ";
          cout << endl;
        } else if (arr1.size() == 2) {
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr0[0].first << " " << arr0[0].second << " ";
          cout << arr0[1].first << " " << arr0[1].second << " ";
          cout << endl;
          cout << arr1[1].first << " " << arr1[1].second << " ";
          cout << arr0[1].first << " " << arr0[1].second << " ";
          cout << arr0[0].first << " " << arr0[0].second << " ";
          cout << endl;
        } else if (arr1.size() == 4) {
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr1[2].first << " " << arr1[2].second << " ";
          cout << arr1[1].first << " " << arr1[1].second << " ";
          cout << endl;
          cout << arr1[3].first << " " << arr1[3].second << " ";
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr1[1].first << " " << arr1[1].second << " ";
          cout << endl;
          cout << arr1[0].first << " " << arr1[0].second << " ";
          cout << arr1[3].first << " " << arr1[3].second << " ";
          cout << arr1[2].first << " " << arr1[2].second << " ";
          cout << endl;
          cout << arr1[3].first << " " << arr1[3].second << " ";
          cout << arr1[1].first << " " << arr1[1].second << " ";
          cout << arr1[2].first << " " << arr1[2].second << " ";
          cout << endl;
        }
        if (j < m - 3) {
          j++;
        }
      }
      if (i < n - 3) {
        i++;
      }
    }
  }
}
