#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, l, n, m, s, c, i, j, k, h, r;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string ar[n];
    for (i = 0; i < n; i++) cin >> ar[i];
    s = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (ar[i][j] == '1') s += 3;
      }
    }
    cout << s << "\n";
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (ar[i - 1][j - 1] == '1') {
          k = 1;
          h = 1;
          if (i == n) k = -1;
          if (j == m) h = -1;
          cout << i << " " << j << " " << i + k << " " << j << " " << i + k
               << " " << j + h << "\n";
          cout << i << " " << j << " " << i << " " << j + h << " " << i + k
               << " " << j + h << "\n";
          cout << i << " " << j << " " << i + k << " " << j << " " << i << " "
               << j + h << "\n";
        }
      }
    }
  }
  return 0;
}
