Problem: This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.

You are given a binary table of size n × m. This table consists of symbols 0 and 1.

You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).

Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.

It can be proved that it is always possible.

Input

The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.

The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).

Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.

It is guaranteed that the sum of nm for all test cases does not exceed 20000.

Output

For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.

In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.

Example

Input


5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101


Output


1
1 1 2 1 2 2
2 
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2 
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2 
1 4 1 5 2 5 
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2

Note

In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.

In the second test case:

  * operation with cells (2, 1), (3, 1), (3, 2). After it the table will be: 
    
          
    011  
    001  
    000  
    

  * operation with cells (1, 2), (1, 3), (2, 3). After it the table will be: 
    
          
    000  
    000  
    000  
    




In the fifth test case:

  * operation with cells (1, 3), (2, 2), (2, 3). After it the table will be: 
    
          
    010  
    110  
    

  * operation with cells (1, 2), (2, 1), (2, 2). After it the table will be: 
    
          
    000  
    000  
    

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
void mini(T& a, T b) {
  a = min(a, b);
}
template <class T>
void maxi(T& a, T b) {
  a = max(a, b);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  return out << a.first << " " << a.second;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, set<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, multiset<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> a) {
  for (auto& i : a) out << i << "\n";
  return out;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, unordered_map<T1, T2> a) {
  for (auto& i : a) out << i << "\n";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, queue<T> a) {
  while (!a.empty()) {
    out << a.front() << " ";
    a.pop();
  }
  return out;
}
template <class T>
ostream& operator<<(ostream& out, deque<T> a) {
  while (!a.empty()) {
    out << a.front() << " ";
    a.pop_front();
  }
  return out;
}
template <class T>
ostream& operator<<(ostream& out, priority_queue<T> a) {
  while (!a.empty()) {
    out << a.top() << "\n";
    a.pop();
  }
  return out;
}
template <class T>
void out(T a) {
  cout << a << endl;
}
template <class T1, class T2>
void out(T1 a, T2 b) {
  cout << a << " " << b << endl;
}
template <class T1, class T2, class T3>
void out(T1 a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << endl;
}
template <class T1, class T2, class T3, class T4>
void out(T1 a, T2 b, T3 c, T4 d) {
  cout << a << " " << b << " " << c << " " << d << endl;
}
template <class T>
void out(vector<vector<T>> a) {
  for (vector<T> i : a) out(i);
}
void out() { cout << "OK" << endl; }
template <class T>
void sort(vector<T>& a) {
  sort(a.begin(), a.end());
}
template <class T>
void uniq(vector<T>& a) {
  sort(a);
  a.erase(unique(a.begin(), a.end()), a.end());
}
template <class T>
vector<T> set_int(vector<T> a, vector<T> b) {
  sort(a);
  sort(b);
  vector<T> res;
  set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(res));
  return res;
}
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
istream& operator>>(istream& in, __int128& a) {
  int64_t b;
  cin >> b;
  a = b;
  return in;
}
ostream& operator<<(ostream& out, const __int128 a) {
  unsigned __int128 b = a < 0 ? -a : a;
  char buf[128];
  char* c = end(buf);
  do {
    --c;
    *c = "0123456789"[b % 10];
    b /= 10;
  } while (b);
  if (a < 0) {
    --c;
    *c = '-';
  }
  int len = end(buf) - c;
  out.rdbuf()->sputn(c, len);
  return out;
}
const int N = 105;
int a[N][N];
vector<int> kek;
void ask(int x1, int y1, int x2, int y2, int x3, int y3) {
  kek.push_back(x1);
  kek.push_back(y1);
  kek.push_back(x2);
  kek.push_back(y2);
  kek.push_back(x3);
  kek.push_back(y3);
  a[x1][y1] ^= 1;
  a[x2][y2] ^= 1;
  a[x3][y3] ^= 1;
}
void ask(vector<pair<int, int>> b) {
  ask(b[0].first, b[0].second, b[1].first, b[1].second, b[2].first,
      b[2].second);
}
void ans() {
  cout << kek.size() / 6 << "\n";
  for (int i = 0; i <= (int)kek.size() / 6 - 1; i++) {
    for (int j = 0; j <= 5; j++) {
      cout << kek[6 * i + j] << " ";
    }
    cout << "\n";
  }
}
void Solve() {
  int T;
  cin >> T;
  while (T--) {
    kek.clear();
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        char c;
        cin >> c;
        a[i][j] = c - '0';
      }
    }
    for (int i = 1; i <= n - 1; i++) {
      for (int j = 1; j <= m - 1; j++) {
        if (a[i][j]) {
          ask(i, j, i + 1, j, i, j + 1);
        }
      }
    }
    for (int j = 1; j <= m - 2; j++) {
      if (a[n][j]) {
        ask(n, j, n, j + 1, n - 1, j + 1);
        ask(n, j + 1, n - 1, j + 1, n, j + 2);
      }
    }
    for (int i = 1; i <= n - 2; i++) {
      if (a[i][m]) {
        ask(i, m, i + 1, m, i + 1, m - 1);
        ask(i + 1, m, i + 1, m - 1, i + 2, m);
      }
    }
    int sum = a[n][m - 1] + a[n][m] + a[n - 1][m];
    if (sum == 1) {
      vector<pair<int, int>> z;
      vector<pair<int, int>> o;
      for (int i = -1; i <= 0; i++) {
        for (int j = -1; j <= 0; j++) {
          if (a[n + i][m + j])
            o.push_back({n + i, m + j});
          else
            z.push_back({n + i, m + j});
        }
      }
      ask(vector<pair<int, int>>{o[0], z[0], z[1]});
      sum++;
    }
    if (sum == 3) {
      ask(n, m - 1, n, m, n - 1, m);
    } else if (sum == 2) {
      vector<pair<int, int>> z;
      vector<pair<int, int>> o;
      for (int i = -1; i <= 0; i++) {
        for (int j = -1; j <= 0; j++) {
          if (a[n + i][m + j])
            o.push_back({n + i, m + j});
          else
            z.push_back({n + i, m + j});
        }
      }
      ask(vector<pair<int, int>>{z[0], z[1], o[0]});
      ask(vector<pair<int, int>>{z[0], z[1], o[1]});
    }
    ans();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  start_time = clock();
  Solve();
  return 0;
}