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>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
long long int myRand(long long int R) {
  long long int val = rng() % R;
  assert(val >= 0);
  return val;
}
const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
const int32_t MOD = 1e9 + 7;
using namespace std;
void my_debugger(string second, long long int LINE_NUM) { cerr << '\n'; }
template <typename start, typename... end>
void my_debugger(string second, long long int LINE_NUM, start x, end... y) {
  if (second.back() != ',') {
    second += ',';
    cerr << "LINE(" << LINE_NUM << "): ";
  }
  long long int i = second.find(',');
  cerr << second.substr(0, i) << " = " << x;
  second = second.substr(i + 1);
  if (!second.empty()) cerr << ", ";
  my_debugger(second, LINE_NUM, y...);
}
vector<tuple<pair<long long int, long long int>,
             pair<long long int, long long int>,
             pair<long long int, long long int>>>
    ans;
long long int a[105][105];
vector<pair<long long int, long long int>> v[2];
void apply(long long int l1, long long int r1, long long int l2,
           long long int r2) {
  ;
  ;
  v[0].clear();
  v[1].clear();
  for (long long int i = l1; i < (long long int)l2 + 1; i++) {
    for (long long int j = r1; j < (long long int)r2 + 1; j++) {
      v[a[i][j]].push_back({i, j});
      ;
      ;
    }
  };
  ;
  long long int siz1 = v[1].size();
  long long int siz2 = v[0].size();
  if (siz1 == 3 || siz1 == 4) {
    ;
    ;
    ans.push_back({{v[1][0].first, v[1][0].second},
                   {v[1][1].first, v[1][1].second},
                   {v[1][2].first, v[1][2].second}});
    for (auto& it : v[1]) a[it.first][it.second] ^= 1;
    if (siz1 == 4) {
      a[v[1][3].first][v[1][3].second] ^= 1;
      apply(l1, r1, l2, r2);
    }
    return;
  } else if (siz1 == 2) {
    ;
    ;
    ans.push_back({{v[1][0].first, v[1][0].second},
                   {v[0][1].first, v[0][1].second},
                   {v[0][0].first, v[0][0].second}});
    pair<long long int, long long int> p1, p2, p3;
    tie(p1, p2, p3) = ans.back();
    for (auto& it : {p1, p2, p3}) a[it.first][it.second] ^= 1;
    apply(l1, r1, l2, r2);
    return;
  } else if (siz1 == 1) {
    ;
    ;
    ans.push_back({{v[1][0].first, v[1][0].second},
                   {v[0][1].first, v[0][1].second},
                   {v[0][0].first, v[0][0].second}});
    pair<long long int, long long int> p1, p2, p3;
    tie(p1, p2, p3) = ans.back();
    for (auto& it : {p1, p2, p3}) a[it.first][it.second] ^= 1;
    apply(l1, r1, l2, r2);
    return;
  }
}
void solve(long long int l1, long long int r1, long long int l2,
           long long int r2) {
  ;
  ;
  long long int rows = l2 - l1 + 1;
  long long int cols = r2 - r1 + 1;
  if (rows == 2 && cols == 3) {
    if (a[l1][r1] == 1 && a[l1 + 1][r1] == 1) {
      apply(l1, r1 + 1, l2, r2);
      apply(l1, r1, l1 + 1, r1 + 1);
    } else {
      apply(l1, r1, l1 + 1, r1 + 1);
      apply(l1, r1 + 1, l2, r2);
    }
  } else
    apply(l1, r1, l2, r2);
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long int tests = 1;
  cin >> tests;
  for (long long int ii = 0; ii < (long long int)tests; ii++) {
    ans.clear();
    long long int n, m;
    cin >> n >> m;
    for (long long int i = 1; i < (long long int)n + 1; i++) {
      string second;
      cin >> second;
      for (long long int j = 0; j < (long long int)second.size(); j++)
        a[i][j + 1] = second[j] - '0';
      for (long long int j = 1; j < (long long int)m + 1; j++)
        ;
      ;
    }
    for (long long int i = 1; i < (long long int)n - 1; i++) {
      for (long long int j = 1; j < (long long int)m; j++) {
        if (a[i][j] == 1) {
          ans.push_back({{i, j}, {i + 1, j + 1}, {i + 1, j}});
          pair<long long int, long long int> p1, p2, p3;
          tie(p1, p2, p3) = ans.back();
          for (auto& it : {p1, p2, p3}) a[it.first][it.second] ^= 1;
        }
      }
      if (a[i][m] == 1) {
        long long int j = m;
        ans.push_back({{i, j}, {i + 1, j - 1}, {i + 1, j}});
        pair<long long int, long long int> p1, p2, p3;
        tie(p1, p2, p3) = ans.back();
        for (auto& it : {p1, p2, p3}) a[it.first][it.second] ^= 1;
      }
    }
    for (long long int j = 1; j <= m; j += 2) {
      if (j + 2 == m) {
        long long int l1 = n - 1, r1 = m - 2, l2 = n, r2 = m;
        solve(l1, r1, l2, r2);
        break;
      }
      solve(n - 1, j, n, j + 1);
    }
    long long int siz = ans.size();
    long long int lim = n * m;
    assert(siz <= lim);
    for (long long int i = 1; i < (long long int)n + 1; i++)
      for (long long int j = 1; j < (long long int)m + 1; j++)
        assert(a[i][j] == 0);
    cout << siz << '\n';
    for (auto& it : ans) {
      pair<long long int, long long int> p1, p2, p3;
      tie(p1, p2, p3) = it;
      cout << p1.first << " " << p1.second << " " << p2.first << " "
           << p2.second << " " << p3.first << " " << p3.second << '\n';
    }
  }
  return 0;
}