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 <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &second) { return '"' + second + '"'; }
string to_string(char c) {
  string second;
  second += c;
  return second;
}
string to_string(const char *second) { return to_string((string)second); }
string to_string(bool b) { return (b ? "1" : "0"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (long long i = 0; i < static_cast<long long>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
void Clearing_out() { return; }
template <typename Head, typename... Tail>
void Clearing_out(Head &H, Tail &...T) {
  H.clear();
  Clearing_out(T...);
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void time() {
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
void hi() {
  static long long i = 0;
  cerr << "Check Point : " << ++i << "\n";
  return;
}
long long stoi1(string str) {
  bool negative;
  if (str[0] == '-') {
    negative = true;
    str = str.substr(1);
  } else {
    negative = false;
  }
  long long n = str.length();
  long long number = 0;
  long long pos = 1;
  for (long long i = n - 1; i >= 0; i--) {
    number = number + (str[i] - '0') * pos;
    pos = pos * 10;
  }
  if (negative) number = -number;
  return number;
}
long long power(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n % 2 != 0) {
      res = res * a;
      n--;
    } else if (n % 2 == 0) {
      a = a * a;
      n = n / 2;
    }
  }
  return res;
}
const long long max_size = 1e6 + 10000;
const double eps = 1e-18;
vector<pair<long long, long long>> v_pr;
vector<string> v_str;
pair<long long, long long> convertor(long long pos) {
  if (pos == 0) {
    return {0, 0};
  } else if (pos == 1) {
    return {0, 1};
  } else if (pos == 2) {
    return {1, 0};
  } else if (pos == 3) {
    return {1, 1};
  }
  return {-1, -1};
}
long long locate(long long a, long long b, long long c, long long d,
                 long long num) {
  if (a == num) return 0;
  if (b == num) return 1;
  if (c == num) return 2;
  if (d == num) return 3;
  return -1;
}
void apply(long long &a, long long &b, long long &c, long long &d,
           long long pos) {
  if (pos == 0) {
    b = 1 - b;
    c = 1 - c;
    d = 1 - d;
  } else if (pos == 1) {
    a = 1 - a;
    c = 1 - c;
    d = 1 - d;
  } else if (pos == 2) {
    a = 1 - a;
    b = 1 - b;
    d = 1 - d;
  } else if (pos == 3) {
    a = 1 - a;
    b = 1 - b;
    c = 1 - c;
  }
  return;
}
set<pair<long long, long long>> st;
void func_sum_1(long long &a, long long &b, long long &c, long long &d,
                pair<long long, long long> present) {
  long long pos = locate(a, b, c, d, 0);
  pair<long long, long long> pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  pos = locate(a, b, c, d, 1);
  pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  pos = locate(a, b, c, d, 0);
  pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  return;
}
void func_sum_2(long long &a, long long &b, long long &c, long long &d,
                pair<long long, long long> present) {
  long long pos = locate(a, b, c, d, 1);
  pair<long long, long long> pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  pos = locate(a, b, c, d, 0);
  pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  return;
}
void func_sum_3(long long &a, long long &b, long long &c, long long &d,
                pair<long long, long long> present) {
  long long pos = locate(a, b, c, d, 0);
  pair<long long, long long> pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  return;
}
void func_sum_4(long long &a, long long &b, long long &c, long long &d,
                pair<long long, long long> present) {
  long long pos = locate(a, b, c, d, 1);
  pair<long long, long long> pr = convertor(pos);
  for (auto x : st) {
    if (x == pr) continue;
    v_pr.push_back({present.first + x.first, present.second + x.second});
  }
  apply(a, b, c, d, pos);
  func_sum_1(a, b, c, d, present);
  return;
}
void solve(long long i, long long j) {
  long long a, b, c, d;
  a = v_str[i][j] - '0';
  b = v_str[i][j + 1] - '0';
  c = v_str[i + 1][j] - '0';
  d = v_str[i + 1][j + 1] - '0';
  long long sum = a + b + c + d;
  if (sum == 1) {
    func_sum_1(a, b, c, d, {i, j});
  } else if (sum == 2) {
    func_sum_2(a, b, c, d, {i, j});
  } else if (sum == 3) {
    func_sum_3(a, b, c, d, {i, j});
  } else if (sum == 4) {
    func_sum_4(a, b, c, d, {i, j});
  } else if (sum == 0) {
  }
  char ch1 = '0' + a;
  v_str[i][j] = ch1;
  char ch2 = '0' + b;
  v_str[i][j + 1] = ch2;
  char ch3 = '0' + c;
  v_str[i + 1][j] = ch3;
  char ch4 = '0' + d;
  v_str[i + 1][j + 1] = ch4;
  return;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  st.insert({0, 0});
  st.insert({0, 1});
  st.insert({1, 0});
  st.insert({1, 1});
  long long t;
  cin >> t;
  while (t--) {
    v_pr.clear();
    v_str.clear();
    long long n, m;
    cin >> n >> m;
    for (long long i = 0; i < n; i++) {
      string str;
      cin >> str;
      v_str.push_back(str);
    }
    for (long long i = 0; i < n - (n & 1); i = i + 2) {
      for (long long j = 0; j < m - (m & 1); j = j + 2) {
        solve(i, j);
      }
    }
    if (n % 2 == 0 && m % 2 == 0) {
    } else if (n % 2 == 0 && m % 2 != 0) {
      for (long long i = 0; i < n; i = i + 2) {
        for (long long j = m - 2; j <= m - 2; j = j + 2) {
          solve(i, j);
        }
      }
    } else if (n % 2 != 0 && m % 2 == 0) {
      for (long long i = n - 2; i <= n - 2; i = i + 2) {
        for (long long j = 0; j < m; j = j + 2) {
          solve(i, j);
        }
      }
    } else if (n % 2 != 0 && m % 2 != 0) {
      for (long long i = 0; i < n - 1; i = i + 2) {
        solve(i, m - 2);
      }
      for (long long j = 0; j < m - 1; j = j + 2) {
        solve(n - 2, j);
      }
      solve(n - 2, m - 2);
    }
    cout << v_pr.size() / 3 << "\n";
    long long count = 0;
    for (auto pr : v_pr) {
      count++;
      cout << pr.first + 1 << " " << pr.second + 1 << " ";
      if (count % 3 == 0) cout << "\n";
    }
    cout << "\n";
    cerr << "["
         << "v_str"
         << "]:",
        debug_out(v_str);
  }
  time();
  return 0;
}