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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;
constexpr long long mod = 1000000007;
const long long INF = mod * mod;
const double eps = 1e-12;
const double pi = acosl(-1.0);
long long mod_pow(long long x, long long n, long long m = mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
struct modint {
  long long n;
  modint() : n(0) { ; }
  modint(long long m) : n(m) {
    if (n >= mod)
      n %= mod;
    else if (n < 0)
      n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) {
  a.n += b.n;
  if (a.n >= mod) a.n -= mod;
  return a;
}
modint operator-=(modint& a, modint b) {
  a.n -= b.n;
  if (a.n < 0) a.n += mod;
  return a;
}
modint operator*=(modint& a, modint b) {
  a.n = ((long long)a.n * b.n) % mod;
  return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, long long n) {
  if (n == 0) return modint(1);
  modint res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
long long inv(long long a, long long p) {
  return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
  fact[0] = modint(1);
  for (int i = 0; i < max_n - 1; i++) {
    fact[i + 1] = fact[i] * modint(i + 1);
  }
  factinv[max_n - 1] = modint(1) / fact[max_n - 1];
  for (int i = max_n - 2; i >= 0; i--) {
    factinv[i] = factinv[i + 1] * modint(i + 1);
  }
}
modint comb(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[b] * factinv[a - b];
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  vector<vector<pair<int, int>>> vs;
  auto tra = [&](char c) -> char {
    if (c == '0')
      return '1';
    else
      return '0';
  };
  for (int i = n - 1; i >= 2; i--)
    for (int j = m - 1; j >= 2; j--) {
      if (s[i][j] == '1') {
        s[i][j] = '0';
        s[i - 1][j] = tra(s[i - 1][j]);
        s[i][j - 1] = tra(s[i][j - 1]);
        vs.push_back({{i, j}, {i - 1, j}, {i, j - 1}});
      }
    }
  for (int i = n - 1; i >= 2; i--) {
    vector<pair<int, int>> cur;
    if (s[i][0] == '1') cur.push_back({i, 0});
    if (s[i][1] == '1') cur.push_back({i, 1});
    if (cur.size() == 0)
      continue;
    else if (cur.size() == 1) {
      cur.push_back({i - 1, 0});
      cur.push_back({i - 1, 1});
      s[i - 1][0] = tra(s[i - 1][0]);
      s[i - 1][1] = tra(s[i - 1][1]);
    } else {
      cur.push_back({i - 1, 0});
      s[i - 1][0] = tra(s[i - 1][0]);
    }
    vs.push_back(cur);
  }
  for (int j = m - 1; j >= 2; j--) {
    vector<pair<int, int>> cur;
    if (s[0][j] == '1') cur.push_back({0, j});
    if (s[1][j] == '1') cur.push_back({1, j});
    if (cur.size() == 0) continue;
    for (int i = 0; i < 2; i++) {
      if (cur.size() == 3) continue;
      s[i][j - 1] = tra(s[i][j - 1]);
      cur.push_back({i, j - 1});
    }
    vs.push_back(cur);
  }
  while (true) {
    vector<pair<int, int>> v[2];
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) v[s[i][j] - '0'].push_back({i, j});
    if (v[1].size() == 0)
      break;
    else if (v[1].size() == 1) {
      vector<pair<int, int>> nex = {v[1][0], v[0][0], v[0][1]};
      vs.push_back(nex);
      for (pair<int, int> p : nex) {
        s[p.first][p.second] = tra(s[p.first][p.second]);
      }
    } else if (v[1].size() == 2) {
      vector<pair<int, int>> nex = {v[0][0], v[0][1], v[1][0]};
      vs.push_back(nex);
      for (pair<int, int> p : nex) {
        s[p.first][p.second] = tra(s[p.first][p.second]);
      }
    } else if (v[1].size() == 3) {
      vector<pair<int, int>> nex = {v[1][0], v[1][1], v[1][2]};
      vs.push_back(nex);
      for (pair<int, int> p : nex) {
        s[p.first][p.second] = tra(s[p.first][p.second]);
      }
    } else {
      vector<pair<int, int>> nex = {v[1][0], v[1][1], v[1][2]};
      vs.push_back(nex);
      for (pair<int, int> p : nex) {
        s[p.first][p.second] = tra(s[p.first][p.second]);
      }
    }
  }
  cout << vs.size() << "\n";
  for (int i = 0; i < vs.size(); i++) {
    for (int j = 0; j < 3; j++) {
      if (j > 0) cout << " ";
      cout << vs[i][j].first + 1 << " " << vs[i][j].second + 1;
    }
    cout << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}