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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
template <typename T>
void ckmin(T& a, const T& b) {
  a = min(a, b);
}
template <typename T>
void ckmax(T& a, const T& b) {
  a = max(a, b);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace __algorithm {
template <typename T>
void dedup(vector<T>& v) {
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
}
template <typename T>
typename vector<T>::const_iterator find(vector<T>& v, const T& x) {
  auto it = lower_bound((v).begin(), (v).end(), x);
  return it != v.end() && *it == x ? it : v.end();
}
template <typename T>
int index(vector<T>& v, const T& x) {
  auto it = find(v, x);
  assert(it != v.end() && *it == x);
  return int(it - v.begin());
}
template <typename C, typename T, typename OP>
vector<T> prefixes(const C& v, T id, OP op) {
  vector<T> r(int((v).size()) + 1, id);
  for (int i = 0; i < (int((v).size())); i++) r[i + 1] = op(r[i], v[i]);
  return r;
}
template <typename C, typename T, typename OP>
vector<T> suffixes(const C& v, T id, OP op) {
  vector<T> r(int((v).size()) + 1, id);
  for (int i = (int((v).size())) - 1; i >= 0; i--) r[i] = op(v[i], r[i + 1]);
  return r;
}
}  // namespace __algorithm
using namespace __algorithm;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
struct __monostate {
  friend istream& operator>>(istream& is, const __monostate& ms) { return is; }
  friend ostream& operator<<(ostream& os, const __monostate& ms) { return os; }
  friend __monostate operator+(const __monostate& a, const __monostate& b) {
    return a;
  }
} ms;
#pragma GCC diagnostic pop
namespace __input {
template <class T1, class T2>
void re(pair<T1, T2>& p);
template <class T>
void re(vector<T>& a);
template <class T, size_t SZ>
void re(array<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& x) {
  string t;
  re(t);
  x = stod(t);
}
template <class Arg, class... Args>
void re(Arg& first, Args&... rest) {
  re(first);
  re(rest...);
}
template <class T1, class T2>
void re(pair<T1, T2>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& a) {
  for (int i = 0; i < (int((a).size())); i++) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ>& a) {
  for (int i = 0; i < (SZ); i++) re(a[i]);
}
}  // namespace __input
using namespace __input;
namespace __output {
template <class T1, class T2>
void pr(const pair<T1, T2>& x);
template <class T, size_t SZ>
void pr(const array<T, SZ>& x);
template <class T>
void pr(const vector<T>& x);
template <class T>
void pr(const set<T>& x);
template <class T1, class T2>
void pr(const map<T1, T2>& x);
template <class T>
void pr(const T& x) {
  cout << x;
}
template <class Arg, class... Args>
void pr(const Arg& first, const Args&... rest) {
  pr(first);
  pr(rest...);
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T, bool pretty = true>
void prContain(const T& x) {
  if (pretty) pr("{");
  bool fst = 1;
  for (const auto& a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
  if (pretty) pr("}");
}
template <class T>
void pc(const T& x) {
  prContain<T, false>(x);
  pr("\n");
}
template <class T, size_t SZ>
void pr(const array<T, SZ>& x) {
  prContain(x);
}
template <class T>
void pr(const vector<T>& x) {
  prContain(x);
}
template <class T>
void pr(const set<T>& x) {
  prContain(x);
}
template <class T1, class T2>
void pr(const map<T1, T2>& x) {
  prContain(x);
}
void ps() { pr("\n"); }
template <class Arg>
void ps(const Arg& first) {
  pr(first);
  ps();
}
template <class Arg, class... Args>
void ps(const Arg& first, const Args&... rest) {
  pr(first, " ");
  ps(rest...);
}
}  // namespace __output
using namespace __output;
struct Op {
  int x1, y1, x2, y2, x3, y3;
};
void solve() {
  int N, M;
  cin >> N >> M;
  vs sgrid(N);
  for (int i = 0; i < N; i++) cin >> sgrid[i];
  vi gridrow(M, 0);
  vvi grid(N, gridrow);
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++) grid[r][c] = sgrid[r][c] - '0';
  vector<Op> ops;
  for (int r = 0; r + 2 < N; r++) {
    for (int c = 0; c < M; c++) {
      if (grid[r][c] == 1) {
        if (c + 1 < M) {
          grid[r][c] ^= 1;
          grid[r + 1][c] ^= 1;
          grid[r + 1][c + 1] ^= 1;
          ops.push_back({r, c, r + 1, c, r + 1, c + 1});
        } else {
          grid[r][c] ^= 1;
          grid[r + 1][c] ^= 1;
          grid[r + 1][c - 1] ^= 1;
          ops.push_back({r, c, r + 1, c, r + 1, c - 1});
        }
      }
    }
  }
  for (int c = 0; c + 2 < M; c++) {
    if (grid[N - 2][c] == 1 && grid[N - 1][c] == 1) {
      grid[N - 2][c] ^= 1;
      grid[N - 1][c] ^= 1;
      grid[N - 2][c + 1] ^= 1;
      ops.push_back({N - 2, c, N - 1, c, N - 2, c + 1});
    } else if (grid[N - 2][c] == 1) {
      grid[N - 2][c] ^= 1;
      grid[N - 1][c + 1] ^= 1;
      grid[N - 2][c + 1] ^= 1;
      ops.push_back({N - 2, c, N - 1, c + 1, N - 2, c + 1});
    } else if (grid[N - 1][c] == 1) {
      grid[N - 1][c] ^= 1;
      grid[N - 1][c + 1] ^= 1;
      grid[N - 2][c + 1] ^= 1;
      ops.push_back({N - 1, c, N - 1, c + 1, N - 2, c + 1});
    }
  }
  int scnt = grid[N - 2][M - 2] + grid[N - 1][M - 2] + grid[N - 2][M - 1] +
             grid[N - 1][M - 1];
  vpii ypts;
  vpii npts;
  for (int r = N - 2; r < N; r++) {
    for (int c = M - 2; c < M; c++) {
      if (grid[r][c] == 1)
        ypts.push_back({r, c});
      else
        npts.push_back({r, c});
    }
  }
  assert(scnt == int((ypts).size()));
  if (scnt == 4) {
    ops.push_back({N - 2, M - 2, N - 1, M - 2, N - 2, M - 1});
    ops.push_back({N - 2, M - 2, N - 1, M - 2, N - 1, M - 1});
    ops.push_back({N - 1, M - 2, N - 1, M - 1, N - 2, M - 1});
    ops.push_back({N - 2, M - 2, N - 2, M - 1, N - 1, M - 1});
  } else if (scnt == 3) {
    ops.push_back({ypts[0].first, ypts[0].second, ypts[1].first, ypts[1].second,
                   ypts[2].first, ypts[2].second});
  } else if (scnt == 2) {
    ops.push_back({ypts[0].first, ypts[0].second, npts[0].first, npts[0].second,
                   npts[1].first, npts[1].second});
    ops.push_back({ypts[1].first, ypts[1].second, npts[0].first, npts[0].second,
                   npts[1].first, npts[1].second});
  } else if (scnt == 1) {
    ops.push_back({ypts[0].first, ypts[0].second, npts[0].first, npts[0].second,
                   npts[1].first, npts[1].second});
    ops.push_back({ypts[0].first, ypts[0].second, npts[0].first, npts[0].second,
                   npts[2].first, npts[2].second});
    ops.push_back({ypts[0].first, ypts[0].second, npts[2].first, npts[2].second,
                   npts[1].first, npts[1].second});
  }
  cout << int((ops).size()) << "\n";
  for (auto op : ops)
    cout << op.x1 + 1 << " " << op.y1 + 1 << " " << op.x2 + 1 << " "
         << op.y2 + 1 << " " << op.x3 + 1 << " " << op.y3 + 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) solve();
  return 0;
}