#include <bits/stdc++.h>   int** arr;   std::vector<int> opers;   void del3(int x, int y) {     if (arr[x][y] && arr[x + 1][y] && arr[x][y + 1]) {       opers.push_back(x + 1);       opers.push_back(y + 1);       opers.push_back(x + 2);       opers.push_back(y + 1);       opers.push_back(x + 1);       opers.push_back(y + 2);       arr[x][y] = 0;       arr[x + 1][y] = 0;       arr[x][y + 1] = 0;     } else if (arr[x][y] && arr[x + 1][y] && arr[x + 1][y + 1]) {       opers.push_back(x + 1);       opers.push_back(y + 1);       opers.push_back(x + 2);       opers.push_back(y + 1);       opers.push_back(x + 2);       opers.push_back(y + 2);       arr[x][y] = 0;       arr[x + 1][y] = 0;       arr[x + 1][y + 1] = 0;     } else if (arr[x][y + 1] == 1 && arr[x + 1][y] && arr[x + 1][y + 1]) {       opers.push_back(x + 1);       opers.push_back(y + 2);       opers.push_back(x + 2);       opers.push_back(y + 1);       opers.push_back(x + 2);       opers.push_back(y + 2);       arr[x][y + 1] = 0;       arr[x + 1][y] = 0;       arr[x + 1][y + 1] = 0;     } else if (arr[x][y] == 1 && arr[x][y + 1] && arr[x + 1][y + 1]) {       opers.push_back(x + 1);       opers.push_back(y + 1);       opers.push_back(x + 1);       opers.push_back(y + 2);       opers.push_back(x + 2);       opers.push_back(y + 2);       arr[x][y] = 0;       arr[x][y + 1] = 0;       arr[x + 1][y + 1] = 0;     }   }   void del2(int x, int y) {     bool fl = false;     if (arr[x][y] == 0) {       opers.push_back(x + 1);       opers.push_back(y + 1);       arr[x][y] = 1;     } else {       if (!fl) {         opers.push_back(x + 1);         opers.push_back(y + 1);         arr[x][y] = 0;         fl = true;       }     }     if (arr[x + 1][y] == 0) {       opers.push_back(x + 2);       opers.push_back(y + 1);       arr[x + 1][y] = 1;     } else {       if (!fl) {         opers.push_back(x + 2);         opers.push_back(y + 1);         fl = true;         arr[x + 1][y] = 0;       }     }     if (arr[x][y + 1] == 0) {       opers.push_back(x + 1);       opers.push_back(y + 2);       arr[x][y + 1] = 1;     } else {       if (!fl) {         opers.push_back(x + 1);         opers.push_back(y + 2);         arr[x][y + 1] = 0;         fl = true;       }     }     if (arr[x + 1][y + 1] == 0) {       opers.push_back(x + 2);       opers.push_back(y + 2);       arr[x + 1][y + 1] = 1;     } else {       if (!fl) {         opers.push_back(x + 2);         opers.push_back(y + 2);         arr[x + 1][y + 1] = 0;         fl = true;       }     }     del3(x, y);   }   void del1(int x, int y) {     int h = 0;     if (arr[x][y] == 1) {       opers.push_back(x + 1);       opers.push_back(y + 1);       arr[x][y] = 0;     } else {       if (h < 2) {         opers.push_back(x + 1);         opers.push_back(y + 1);         arr[x][y] = 1;         h++;       }     }     if (arr[x + 1][y] == 1) {       opers.push_back(x + 2);       opers.push_back(y + 1);       arr[x + 1][y] = 0;     } else {       if (h < 2) {         opers.push_back(x + 2);         opers.push_back(y + 1);         arr[x + 1][y] = 1;         h++;       }     }     if (arr[x][y + 1] == 1) {       opers.push_back(x + 1);       opers.push_back(y + 2);       arr[x][y + 1] = 0;     } else {       if (h < 2) {         opers.push_back(x + 1);         opers.push_back(y + 2);         arr[x][y + 1] = 1;         h++;       }     }     if (arr[x + 1][y + 1] == 1) {       opers.push_back(x + 2);       opers.push_back(y + 2);       arr[x + 1][y + 1] = 0;     } else {       if (h < 2) {         opers.push_back(x + 2);         opers.push_back(y + 2);         arr[x + 1][y + 1] = 1;         h++;       }     }     del2(x, y);   }   void setup(int x, int y) {     int iu = arr[x][y] + arr[x][y + 1] + arr[x + 1][y] + arr[x + 1][y + 1];     if (iu == 3) {       del3(x, y);     } else if (iu == 2) {       del2(x, y);     } else if (iu == 1) {       del1(x, y);     } else if (iu == 4) {       del3(x, y);       del1(x, y);     }     arr[x][y] = 0;     arr[x][y + 1] = 0;     arr[x + 1][y] = 0;     arr[x + 1][y + 1] = 0;   }   int main() {     int t;     std::cin >> t;     for (int i = 0; i < t; i++) {       int n, m;       std::cin >> n >> m;       arr = new int*[n];       for (int i = 0; i < n; i++) arr[i] = new int[m];       for (int i = 0; i < n; i++) {         std::string s;         std::cin >> s;         for (int j = 0; j < s.size(); j++) {           arr[i][j] = s[j] -  0 ;         }       }       for (int a = 0; a < n - 1; a++) {         for (int b = 0; b < m - 1; b++) {           setup(a, b);         }       }       std::cout << opers.size() / 6 <<   n ;       for (int i = 0; i < opers.size() / 6; i++) {         for (int j = 0; j < 6; j++) {           std::cout << opers[i * 6 + j] <<    ;         }         std::cout <<   n ;       }       opers.clear();     }     return 0;   }