#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == '1') {
          count += 3;
        }
      }
    }
    cout << count << endl;
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < m + 1; j++) {
        int a = 1;
        int b = 1;
        if (j - 1 == m - 1) {
          b = -1;
        }
        if (i - 1 == n - 1) {
          a = -1;
        }
        if (s[i - 1][j - 1] == '1') {
          cout << i << " " << j << " " << i << " " << j + b << " " << i + a
               << " " << j + b << endl;
          cout << i << " " << j << " " << i + a << " " << j << " " << i + a
               << " " << j + b << endl;
          cout << i << " " << j << " " << i + a << " " << j << " " << i << " "
               << j + b << endl;
        }
      }
    }
  }
  return 0;
}
