#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265359;
inline long long add(long long a, long long b, long long m) {
  if ((a + b) >= m) return (a + b) % m;
  return a + b;
}
inline long long mul(long long a, long long b, long long m) {
  if ((a * b) < m) return a * b;
  return (a * b) % m;
}
long long power(long long x, long long y, long long m) {
  long long res = 1;
  x = x % m;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    y = y >> 1;
    x = (x * x) % m;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void three(vector<string>& v, vector<vector<int>>& temp,
           vector<vector<int>>& ans) {
  vector<int> res;
  for (int i = 0; i < 4; i++) {
    if (v[temp[i][0]][temp[i][1]] == '1') {
      v[temp[i][0]][temp[i][1]] = '0';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
    }
  }
  ans.push_back(res);
}
void two(vector<string>& v, vector<vector<int>>& temp,
         vector<vector<int>>& ans) {
  int c = 0;
  vector<int> res;
  for (int i = 0; i < 4; i++) {
    if (v[temp[i][0]][temp[i][1]] == '0') {
      v[temp[i][0]][temp[i][1]] = '1';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
    } else if (c < 1) {
      v[temp[i][0]][temp[i][1]] = '0';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
      c++;
    }
  }
  ans.push_back(res);
  three(v, temp, ans);
}
void one(vector<string>& v, vector<vector<int>>& temp,
         vector<vector<int>>& ans) {
  int c = 0;
  vector<int> res;
  for (int i = 0; i < 4; i++) {
    if (v[temp[i][0]][temp[i][1]] == '1') {
      v[temp[i][0]][temp[i][1]] = '0';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
    } else if (c < 2) {
      v[temp[i][0]][temp[i][1]] = '1';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
      c++;
    }
  }
  ans.push_back(res);
  two(v, temp, ans);
}
void four(vector<string>& v, vector<vector<int>>& temp,
          vector<vector<int>>& ans) {
  int c = 0;
  vector<int> res;
  for (int i = 0; i < 4; i++) {
    if (v[temp[i][0]][temp[i][1]] == '1' && c < 3) {
      v[temp[i][0]][temp[i][1]] = '0';
      res.push_back(temp[i][0]);
      res.push_back(temp[i][1]);
      c++;
    }
  }
  ans.push_back(res);
  one(v, temp, ans);
}
int co(vector<string>& v, vector<vector<int>>& temp) {
  int c = 0;
  for (int i = 0; i < 4; i++)
    if (v[temp[i][0]][temp[i][1]] == '1') {
      c++;
    }
  return c;
}
int main() {
  ios_base::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  int t = 1, n, m;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    vector<vector<int>> res;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (v[i][j] == '0') {
          continue;
        }
        vector<vector<int>> temp;
        int c = 0;
        if (i + 1 < n && j + 1 < m) {
          temp.push_back({i, j});
          temp.push_back({i + 1, j});
          temp.push_back({i, j + 1});
          temp.push_back({i + 1, j + 1});
        } else if (i + 1 < n && j - 1 >= 0) {
          temp.push_back({i, j});
          temp.push_back({i + 1, j});
          temp.push_back({i, j - 1});
          temp.push_back({i + 1, j - 1});
        } else if (i - 1 >= 0 && j + 1 < m) {
          temp.push_back({i, j});
          temp.push_back({i - 1, j});
          temp.push_back({i, j + 1});
          temp.push_back({i - 1, j + 1});
        } else {
          temp.push_back({i, j});
          temp.push_back({i - 1, j});
          temp.push_back({i, j - 1});
          temp.push_back({i - 1, j - 1});
        }
        c = co(v, temp);
        if (c == 1) {
          one(v, temp, res);
        } else if (c == 2) {
          two(v, temp, res);
        } else if (c == 3) {
          three(v, temp, res);
        } else {
          four(v, temp, res);
        }
      }
    }
    cout << res.size() << endl;
    for (auto u : res) {
      for (auto v : u) {
        cout << v + 1 << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
