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 pii = pair<int, int>;
const int N = 105;
pii ans[N * N][3];
int pt;
int a[N][N];
char s[N][N];
void push(pii p1, pii p2, pii p3) {
  pt++;
  ans[pt][0] = p1;
  ans[pt][1] = p2;
  ans[pt][2] = p3;
  a[p1.first][p1.second] = 1 - a[p1.first][p1.second];
  a[p2.first][p2.second] = 1 - a[p2.first][p2.second];
  a[p3.first][p3.second] = 1 - a[p3.first][p3.second];
  return;
}
void solve_2(int r, int c) {
  vector<pii> v[2];
  for (int i = r; i <= r + 1; i++) {
    for (int j = c; j <= c + 1; j++) {
      v[a[i][j]].push_back({i, j});
    }
  }
  if ((int)v[1].size() == 4) {
    push(v[1][1], v[1][2], v[1][3]);
    for (int i = 1; i <= 3; i++) {
      v[0].push_back(v[1].back());
      v[1].pop_back();
    }
  }
  if ((int)v[1].size() == 1) {
    push(v[1][0], v[0][1], v[0][2]);
    pii p = v[1][0];
    v[1].pop_back();
    v[1].push_back(v[0][1]), v[1].push_back(v[0][2]);
    v[0].pop_back(), v[0].pop_back();
    v[0].push_back(p);
  }
  if ((int)v[1].size() == 2) {
    push(v[0][0], v[0][1], v[1][1]);
    pii p = v[1][1];
    v[1].pop_back();
    for (int i = 0; i < 2; i++) {
      v[1].push_back(v[0].back());
      v[0].pop_back();
    }
    v[0].push_back(p);
  }
  if ((int)v[1].size() == 3) {
    push(v[1][0], v[1][1], v[1][2]);
  }
  return;
}
void solve_3(int r, int c) {
  int cnt[3] = {};
  for (int i = r; i <= r + 1; i++) {
    for (int j = c; j <= c + 2; j++) {
      cnt[j - c] += a[i][j];
    }
  }
  if (cnt[0] == 1) {
    pii p = {a[r][c] == 0 ? r + 1 : r, c};
    pii q = {a[r][c] == 0 ? r : r + 1, c};
    if (cnt[1] == 0 && cnt[2] == 2) {
      push(q, {r, c + 1}, {r + 1, c + 1});
      cnt[0] = cnt[1] = 2;
    } else {
      push(p, {r, c + 1}, {r + 1, c + 1});
    }
  }
  if (cnt[0] == 2) {
    if (a[r][c + 1] == 1)
      push({r, c}, {r + 1, c}, {r, c + 1});
    else
      push({r, c}, {r + 1, c}, {r + 1, c + 1});
  }
  solve_2(r, c + 1);
}
void clear_2(pii p1, pii p2, pii q1, pii q2) {
  pii p[2] = {p1, p2}, q[2] = {q1, q2};
  if (a[p1.first][p1.second] == 0 && a[p2.first][p2.second] == 0) return;
  if (a[p1.first][p1.second] == 1 && a[p2.first][p2.second] == 1) {
    push(p1, p2, q1);
    return;
  }
  if (a[p1.first][p1.second] == 1) {
    push(p1, q1, q2);
    return;
  } else
    push(p2, q1, q2);
  return;
}
void printAns() {
  printf("%d\n", pt);
  for (int i = 1; i <= pt; i++) {
    for (int j = 0; j < 3; j++) {
      printf("%d %d ", ans[i][j].first, ans[i][j].second);
    }
    printf("\n");
  }
  return;
}
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  pt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= m; j++) a[i][j] = s[i][j] - '0';
  }
  if (m == 2 && n == 2) {
    solve_2(1, 1);
    printAns();
    return;
  }
  if (n & 1) {
    for (int i = 1; i <= m; i += 2) {
      clear_2({1, i}, {1, i + (i == m ? -1 : 1)}, {2, i},
              {2, i + (i == m ? -1 : 1)});
    }
  }
  for (int i = 1 + (n & 1); i <= n; i += 2) {
    for (int j = 1; j < m; j++) {
      if (j + 1 == m) {
        solve_2(i, j);
        break;
      }
      if (j + 2 == m) {
        solve_3(i, j);
        break;
      }
      clear_2({i, j}, {i + 1, j}, {i + 1, j + 1}, {i, j + 1});
    }
  }
  printAns();
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}