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;
bool check(long long n, long long pos) { return n & (1LL << pos); }
long long Set(long long n, long long pos) { return n = n | (1LL << pos); }
char grid[103][103];
struct info {
  long long x1, y1, x2, y2, x3, y3;
};
vector<info> seq;
long long n, m;
void toggle(long long x, long long y) {
  assert(x <= n && y <= m);
  if (grid[x][y] == '0')
    grid[x][y] = '1';
  else
    grid[x][y] = '0';
  return;
}
void alter(long long x, long long y) {
  info ret;
  toggle(x, y);
  ret.x1 = x;
  ret.y1 = y;
  if (grid[x][y + 1] == '0') {
    toggle(x + 1, y);
    ret.x2 = x + 1;
    ret.y2 = y;
    if (y < m) {
      toggle(x + 1, y + 1);
      ret.x3 = x + 1;
      ret.y3 = y + 1;
    } else {
      toggle(x + 1, y - 1);
      ret.x3 = x + 1;
      ret.y3 = y - 1;
    }
  } else {
    toggle(x, y + 1);
    ret.x2 = x;
    ret.y2 = y + 1;
    if (y < m) {
      toggle(x + 1, y + 1);
      ret.x3 = x + 1;
      ret.y3 = y + 1;
    } else {
      toggle(x + 1, y);
      ret.x3 = x + 1;
      ret.y3 = y;
    }
  }
  seq.push_back(ret);
  return;
}
void solve3(long long x) {
  long long cnt = 4;
  info ret;
  for (long long i = n - 1; i <= n; i++) {
    for (long long j = x; j <= x + 1; j++) {
      if (grid[i][j] == '1') {
        cnt--;
        if (cnt == 0) continue;
        toggle(i, j);
        if (cnt == 3) ret.x1 = i, ret.y1 = j;
        if (cnt == 2) ret.x2 = i, ret.y2 = j;
        if (cnt == 1) {
          ret.x3 = i, ret.y3 = j;
        }
      }
    }
  }
  seq.push_back(ret);
  assert(cnt == 1);
  return;
}
void solve2(long long x) {
  long long cnt1 = 1, cnt2 = 2;
  info ret;
  for (long long i = n - 1; i <= n; i++) {
    for (long long j = x; j <= x + 1; j++) {
      if (grid[i][j] == '1') {
        cnt1--;
        if (cnt1 == 0) {
          toggle(i, j);
          ret.x3 = i, ret.y3 = j;
        }
      } else {
        cnt2--;
        if (cnt2 == 1) {
          toggle(i, j);
          ret.x1 = i, ret.y1 = j;
        }
        if (cnt2 == 0) {
          toggle(i, j);
          ret.x2 = i, ret.y2 = j;
        }
      }
    }
  }
  assert(cnt1 == -1 && cnt2 == 0);
  seq.push_back(ret);
  solve3(x);
  return;
}
void solve1(long long x) {
  long long cnt1 = 1, cnt2 = 2;
  info ret;
  for (long long i = n - 1; i <= n; i++) {
    for (long long j = x; j <= x + 1; j++) {
      if (grid[i][j] == '1') {
        cnt1--;
        if (cnt1 == 0) {
          toggle(i, j);
          ret.x3 = i, ret.y3 = j;
        }
      } else {
        cnt2--;
        if (cnt2 == 1) {
          toggle(i, j);
          ret.x1 = i, ret.y1 = j;
        }
        if (cnt2 == 0) {
          toggle(i, j);
          ret.x2 = i, ret.y2 = j;
        }
      }
    }
  }
  assert(cnt1 == 0 && cnt2 == -1);
  seq.push_back(ret);
  solve2(x);
  return;
}
void solve4(long long x) {
  long long cnt = 4;
  info ret;
  for (long long i = n - 1; i <= n; i++) {
    for (long long j = x; j <= x + 1; j++) {
      if (grid[i][j] == '1') {
        cnt--;
        if (cnt == 0) continue;
        toggle(i, j);
        if (cnt == 3) ret.x1 = i, ret.y1 = j;
        if (cnt == 2) ret.x2 = i, ret.y2 = j;
        if (cnt == 1) {
          ret.x3 = i, ret.y3 = j;
        }
      }
    }
  }
  assert(cnt == 0);
  seq.push_back(ret);
  solve1(x);
  return;
}
void solve(long long x) {
  long long cnt = 0;
  for (long long i = n - 1; i <= n; i++) {
    for (long long j = x; j <= x + 1; j++) {
      if (grid[i][j] == '1') cnt++;
    }
  }
  if (cnt == 4)
    solve4(x);
  else if (cnt == 3)
    solve3(x);
  else if (cnt == 2)
    solve2(x);
  else if (cnt == 1)
    solve1(x);
  return;
}
void alter1(long long x, long long y) {
  info ret;
  ret.x1 = x;
  ret.y1 = y;
  ret.x2 = x - 1;
  ret.y2 = y + 1;
  ret.x3 = x;
  ret.y3 = y + 1;
  toggle(x, y);
  toggle(x - 1, y + 1);
  toggle(x, y + 1);
  seq.push_back(ret);
  return;
}
int main() {
  long long i, j, k, l, o, r, q;
  long long testcase;
  long long input, flag, tag, ans;
  scanf("%lld", &testcase);
  for (long long cs = 1; cs <= testcase; cs++) {
    seq.clear();
    cin >> n >> m;
    for (long long i = 1; i <= n; i++) cin >> grid[i] + 1;
    for (long long i = 1; i <= n; i++) grid[i][m + 1] = '0';
    for (long long i = 1; i <= n - 2; i++) {
      for (long long j = 1; j <= m; j++) {
        if (grid[i][j] == '1') alter(i, j);
      }
    }
    if (m & 1) {
      if (grid[n - 1][1] == '1') alter(n - 1, 1);
      if (grid[n][1] == '1') alter1(n, 1);
      for (long long i = 2; i <= m; i += 2) {
        solve(i);
      }
    } else {
      for (long long i = 1; i <= m; i += 2) {
        solve(i);
      }
    }
    cout << seq.size() << "\n";
    for (info it : seq) {
      cout << it.x1 << " " << it.y1 << " " << it.x2 << " " << it.y2 << " "
           << it.x3 << " " << it.y3 << "\n";
    }
    assert(seq.size() <= (n * m));
  }
}