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 optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T>
using vec = std::vector<T>;
template <class T>
using vec2d = std::vector<std::vector<T>>;
template <class T>
vec2d<T> makeVec2d(const int n1, const int n2) {
  return vec2d<T>(n1, vec<T>(n2));
}
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
template <class T>
void addOne(vec<T> &v) {
  for_each(v.begin(), v.end(), [](T &el) { ++el; });
}
struct Input {
  Input(istream &in) : in(&in) {}
  template <class T>
  T next() const {
    T x;
    *in >> x;
    return x;
  }
  int ni() const { return next<int>(); }
  string ns() const { return next<string>(); }
  istream *in;
};
Input in(cin);
class Output {
 private:
  ostream *out;
  template <typename T>
  void printSingle(const T &value) {
    *out << value;
  }
  template <typename T>
  void printSingle(const vec<T> &v) {
    for (std::size_t i = 0; i < v.size(); ++i) {
      if (i == 0) {
        printSingle(v[i]);
      } else {
        *out << ' ';
        printSingle(v[i]);
      }
    }
  }

 public:
  Output(ostream &out) : out(&out) {}
  inline void print() {}
  template <typename T, typename... Ts>
  inline void print(const T &f, const Ts &...args) {
    printSingle(f);
    if (sizeof...(args) != 0) {
      *out << ' ';
      print(args...);
    }
  }
  template <typename... Ts>
  inline void println(const Ts &...args) {
    print(args...);
    (*out) << '\n';
  }
  template <typename... Ts>
  inline void operator()(const Ts &...args) {
    println(args...);
  }
};
Output out(cout);
namespace template_util {
constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }
template <int N>
struct bytetype {};
template <uint64_t N>
struct minimal_uint : bytetype<bytecount(N)> {};
}  // namespace template_util
void solveOne() {
  auto n = in.ni();
  auto m = in.ni();
  vec2d<int> a = makeVec2d<int>(n, m);
  for (int i = 0; i < (n); ++i) {
    string s = in.ns();
    for (int j = 0; j < (m); ++j) {
      a[i][j] = s[j] - '0';
    }
  }
  vec2d<int> res;
  auto doOper1 = [&](int x, int y) {
    a[x][y] ^= 1;
    a[x + 1][y] ^= 1;
    a[x][y + 1] ^= 1;
    res.push_back({x, y, x + 1, y, x, y + 1});
  };
  auto doOper2 = [&](int x, int y) {
    a[x][y] ^= 1;
    a[x + 1][y] ^= 1;
    a[x + 1][y - 1] ^= 1;
    res.push_back({x, y, x + 1, y, x + 1, y - 1});
  };
  for (int i = 0; i < (n - 2); ++i) {
    for (int j = 0; j < (m - 1); ++j) {
      if (a[i][j] == 1) {
        doOper1(i, j);
      }
    }
    if (a[i][m - 1] == 1) {
      doOper2(i, m - 1);
    }
  }
  int r1 = n - 2, r2 = n - 1;
  for (int j = 0; j < (m - 2); ++j) {
    if (a[r1][j] == a[r2][j]) {
      if (a[r1][j] == 1) {
        a[r1][j] ^= 1;
        a[r2][j] ^= 1;
        a[r1][j + 1] ^= 1;
        res.push_back({r1, j, r2, j, r1, j + 1});
      }
    } else if (a[r1][j] == 1 && a[r2][j] == 0) {
      a[r1][j] ^= 1;
      a[r2][j + 1] ^= 1;
      a[r1][j + 1] ^= 1;
      res.push_back({r1, j, r2, j + 1, r1, j + 1});
    } else if (a[r1][j] == 0 && a[r2][j] == 1) {
      a[r2][j] ^= 1;
      a[r2][j + 1] ^= 1;
      a[r1][j + 1] ^= 1;
      res.push_back({r2, j, r2, j + 1, r1, j + 1});
    }
  }
  int c1 = m - 2, c2 = m - 1;
  int cnt = 0;
  for (int i = (r1); i <= (r2); ++i) {
    for (int j = (c1); j <= (c2); ++j) {
      cnt += a[i][j];
    }
  }
  while (true) {
    cnt = 0;
    for (int i = (r1); i <= (r2); ++i) {
      for (int j = (c1); j <= (c2); ++j) {
        cnt += a[i][j];
      }
    }
    if (cnt == 0) {
      out(res.size());
      for (auto v : res) {
        addOne(v);
        out(v);
      }
      return;
    }
    if (cnt == 1) {
      vec<int> add;
      int cnt0 = 0;
      for (int i = (r1); i <= (r2); ++i) {
        for (int j = (c1); j <= (c2); ++j) {
          if (cnt0 < 2 && a[i][j] == 0) {
            ++cnt0;
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
            continue;
          }
          if (a[i][j] == 1) {
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
            continue;
          }
        }
      }
      res.push_back(add);
      continue;
    }
    if (cnt == 2) {
      vec<int> add;
      int cnt1 = 0;
      for (int i = (r1); i <= (r2); ++i) {
        for (int j = (c1); j <= (c2); ++j) {
          if (a[i][j] == 0) {
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
            continue;
          }
          if (cnt1 == 0 && a[i][j] == 1) {
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
            ++cnt1;
            continue;
          }
        }
      }
      res.push_back(add);
      continue;
    }
    if (cnt == 3) {
      vec<int> add;
      for (int i = (r1); i <= (r2); ++i) {
        for (int j = (c1); j <= (c2); ++j) {
          if (a[i][j] == 1) {
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
          }
        }
      }
      res.push_back(add);
      continue;
    }
    if (cnt == 4) {
      vec<int> add;
      int cnt1 = 0;
      for (int i = (r1); i <= (r2); ++i) {
        for (int j = (c1); j <= (c2); ++j) {
          if (cnt1 < 3 && a[i][j] == 1) {
            add.push_back(i);
            add.push_back(j);
            a[i][j] ^= 1;
            ++cnt1;
          }
        }
      }
      res.push_back(add);
      continue;
    }
  }
}
void solve(istream &inStream, ostream &outStream) {
  in = Input(inStream);
  out = Output(outStream);
  auto tests = in.ni();
  while (tests--) {
    solveOne();
  }
}
int main() {
  solve(cin, cout);
  return 0;
}