#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
const int inf = 0x3f3f3f3f;
void check_max(int &a, int b) { a = max(a, b); }
void check_min(int &a, int b) { a = min(a, b); }
int maze[maxn][maxn];
int n, m;
int moving[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
bool check(int x, int y) {
  int nx = x + 1, ny = y + 1;
  if (nx > n || ny > m) return false;
  return true;
}
int calc(int x, int y) {
  int res = 0;
  for (int i = 0; i < 4; i++) {
    int nx = x + moving[i][0], ny = moving[i][1] + y;
    if (maze[nx][ny] == 1) res++;
  }
  return res;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%1d", &maze[i][j]);
    int ans = 0;
    vector<pair<int, int> > st;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (check(i, j)) {
          if (calc(i, j) == 0)
            continue;
          else if (calc(i, j) == 1) {
            ans += 3;
            int sign = 0;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                st.push_back({nx, ny});
                maze[nx][ny] = 0;
              } else if (sign != 2 && maze[nx][ny] == 0) {
                sign++;
                st.push_back({nx, ny});
                maze[nx][ny] = 1;
              }
            }
            int flag = 0;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 0) {
                st.push_back({nx, ny});
                maze[nx][ny] = 1;
              } else if (maze[nx][ny] == 1 && !flag) {
                st.push_back({nx, ny});
                maze[nx][ny] = 0;
                flag = 1;
              }
            }
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                maze[nx][ny] = 0;
                st.push_back({nx, ny});
              }
            }
          } else if (calc(i, j) == 2) {
            ans += 2;
            int flag = 0;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 0) {
                st.push_back({nx, ny});
                maze[nx][ny] = 1;
              } else if (maze[nx][ny] == 1 && !flag) {
                st.push_back({nx, ny});
                maze[nx][ny] = 0;
                flag = 1;
              }
            }
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                maze[nx][ny] = 0;
                st.push_back({nx, ny});
              }
            }
          } else if (calc(i, j) == 3) {
            ans += 1;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                maze[nx][ny] = 0;
                st.push_back({nx, ny});
              }
            }
          } else if (calc(i, j) == 4) {
            ans += 4;
            for (int k = 0; k < 3; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              st.push_back({nx, ny});
              maze[nx][ny] = 0;
            }
            int sign = 0;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                st.push_back({nx, ny});
                maze[nx][ny] = 0;
              } else if (sign != 2 && maze[nx][ny] == 0) {
                sign++;
                st.push_back({nx, ny});
                maze[nx][ny] = 1;
              }
            }
            int flag = 0;
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 0) {
                st.push_back({nx, ny});
                maze[nx][ny] = 1;
              } else if (maze[nx][ny] == 1 && !flag) {
                st.push_back({nx, ny});
                maze[nx][ny] = 0;
                flag = 1;
              }
            }
            for (int k = 0; k < 4; k++) {
              int nx = i + moving[k][0], ny = j + moving[k][1];
              if (maze[nx][ny] == 1) {
                maze[nx][ny] = 0;
                st.push_back({nx, ny});
              }
            }
          }
        }
    printf("%d\n", ans);
    for (int i = 0; i < st.size(); i++) {
      printf("%d %d ", st[i].first, st[i].second);
      if ((i + 1) % 3 == 0) printf("\n");
    }
  }
  return 0;
}
