#include <bits/stdc++.h>
using namespace std;
long long int binexpo(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    x = x * x;
    y = y >> 1;
  }
  return res;
}
int main() {
  long long int t;
  t = 1;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int arr[n][m];
    for (long long int i = 0; i < n; i++) {
      string str;
      cin >> str;
      for (long long int j = 0; j < str.length(); j++) {
        arr[i][j] = str[j] - '0';
      }
    }
    vector<vector<long long int>> k;
    long long int res = 0;
    for (long long int i = 0; i <= n - 2; i++) {
      for (long long int j = 0; j <= m - 2; j++) {
        vector<long long int> v;
        long long int total = 0;
        long long int first = 0, second = 0, third = 0, fourth = 0;
        if (arr[i][j] == 1) {
          total++;
          first = 1;
        }
        if (arr[i + 1][j] == 1) {
          total++;
          second = 1;
        }
        if (arr[i][j + 1] == 1) {
          total++;
          third = 1;
        }
        if (arr[i + 1][j + 1] == 1) {
          total++;
          fourth = 1;
        }
        if (total == 4) {
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          arr[i + 1][j] = 0;
          arr[i][j + 1] = 0;
          arr[i + 1][j + 1] = 0;
        }
      }
    }
    for (long long int i = 0; i <= n - 2; i++) {
      for (long long int j = 0; j <= m - 2; j++) {
        vector<long long int> v;
        long long int total = 0;
        long long int first = 0, second = 0, third = 0, fourth = 0;
        if (arr[i][j] == 1) {
          total++;
          first = 1;
        }
        if (arr[i + 1][j] == 1) {
          total++;
          second = 1;
        }
        if (arr[i][j + 1] == 1) {
          total++;
          third = 1;
        }
        if (arr[i + 1][j + 1] == 1) {
          total++;
          fourth = 1;
        }
        if (total == 3) {
          if (first == 1) {
            arr[i][j] = 0;
            v.push_back(i);
            v.push_back(j);
          }
          if (second == 1) {
            arr[i + 1][j] = 0;
            v.push_back(i + 1);
            v.push_back(j);
          }
          if (third == 1) {
            arr[i][j + 1] = 0;
            v.push_back(i);
            v.push_back(j + 1);
          }
          if (fourth == 1) {
            arr[i + 1][j + 1] = 0;
            v.push_back(i + 1);
            v.push_back(j + 1);
          }
          k.push_back(v);
          res++;
        }
      }
    }
    for (long long int i = 0; i <= n - 2; i++) {
      for (long long int j = 0; j <= m - 2; j++) {
        vector<long long int> v;
        if (arr[i + 1][j] == 1 && arr[i + 1][j + 1] == 1) {
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          k.push_back(v);
          res++;
          v.clear();
          arr[i + 1][j] = 0;
          arr[i + 1][j + 1] = 0;
        } else if (arr[i][j + 1] == 1 && arr[i + 1][j + 1] == 1) {
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j + 1] = 0;
          arr[i + 1][j + 1] = 0;
        } else if (arr[i + 1][j] == 1 && arr[i][j + 1] == 1) {
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j + 1] = 0;
          arr[i + 1][j] = 0;
        } else if (arr[i][j] == 1 && arr[i + 1][j] == 1) {
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j] = 0;
          arr[i + 1][j] = 0;
        } else if (arr[i][j] == 1 && arr[i + 1][j + 1] == 1) {
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j] = 0;
          arr[i + 1][j + 1] = 0;
        } else if (arr[i][j] == 1 && arr[i][j + 1] == 1) {
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j] = 0;
          arr[i][j + 1] = 0;
        } else if (arr[i + 1][j] == 1 && arr[i][j + 1] == 1) {
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          k.push_back(v);
          res++;
          v.clear();
          arr[i][j + 1] = 0;
          arr[i + 1][j] = 0;
        }
      }
    }
    for (long long int i = 0; i <= n - 2; i++) {
      for (long long int j = 0; j <= m - 2; j++) {
        vector<long long int> v;
        long long int total = 0;
        long long int first = 0, second = 0, third = 0, fourth = 0;
        if (arr[i][j] == 1) {
          total++;
          first = 1;
        }
        if (arr[i + 1][j] == 1) {
          total++;
          second = 1;
        }
        if (arr[i][j + 1] == 1) {
          total++;
          third = 1;
        }
        if (arr[i + 1][j + 1] == 1) {
          total++;
          fourth = 1;
        }
        if (total == 1) {
          if (first == 1) {
            v.push_back(i);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            k.push_back(v);
            res++;
            v.clear();
            arr[i][j] = 0;
          }
          if (second == 1) {
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            k.push_back(v);
            res++;
            v.clear();
            arr[i + 1][j] = 0;
          }
          if (third == 1) {
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            arr[i][j + 1] = 0;
          }
          if (fourth == 1) {
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j);
            k.push_back(v);
            res++;
            v.clear();
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j + 1);
            k.push_back(v);
            res++;
            v.clear();
            arr[i + 1][j + 1] = 0;
          }
        }
      }
    }
    cout << res << "\n";
    for (long long int i = 0; i < k.size(); i++) {
      for (long long int j = 0; j < k[i].size(); j++) {
        cout << k[i][j] + 1 << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
