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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA1 solver = new TaskA1();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int T = in.nextInt();
            while (T-- > 0) {
                int N = in.nextInt();
                int M = in.nextInt();
                char[][] board = new char[N][];
                for (int i = 0; i < N; i++) {
                    board[i] = in.next().toCharArray();
                }
                ArrayList<int[]> ans = new ArrayList<>();
                int i = 0;
                int j = 0;
                while (true) {
                    if (i >= N) {
                        j += 2;
                        if (j == M - 1) {
                            j--;
                        }
                        if (j >= M) {
                            break;
                        }
                        i = 0;
                    }
                    if (i == N - 1) {
                        i--;
                    }
                    if (j != M - 2 && i != N - 2 && board[i][j] != '1' && board[i][j + 1] != '1') {
                        i++;
                    } else if (i == N - 2 || j == M - 2) {
                        int cnt = 0;
                        if (board[i][j] == '1') {
                            cnt++;
                        }
                        if (board[i + 1][j] == '1') {
                            cnt++;
                        }
                        if (board[i][j + 1] == '1') {
                            cnt++;
                        }
                        if (board[i + 1][j + 1] == '1') {
                            cnt++;
                        }
                        int[][] next = null;
                        if (cnt == 4) {
                            next = four(board, i, j);
                        } else if (cnt == 3) {
                            next = three(board, i, j);
                        } else if (cnt == 2) {
                            next = two(board, i, j);
                        } else if (cnt == 1) {
                            next = one(board, i, j);
                        }
                        if (next != null) {
                            for (int[] n : next) {
                                ans.add(n);
                            }
                        }
                        i += 2;
                    } else {
                        int[] b = new int[6];
                        int c = 0;
                        if (board[i][j] == '1') {
                            b[0] = i;
                            b[1] = j;
                            rev(board, i, j);
                            c++;
                        }
                        if (board[i][j + 1] == '1') {
                            b[2 * c] = i;
                            b[2 * c + 1] = j + 1;
                            rev(board, i, j + 1);
                            c++;
                        }
                        if (c == 1) {
                            b[2] = i + 1;
                            b[3] = j + 1;
                            b[4] = i + 1;
                            b[5] = j;
                            rev(board, i + 1, j + 1);
                            rev(board, i + 1, j);
                        } else if (c == 2) {
                            b[4] = i + 1;
                            b[5] = j + 1;
                            rev(board, i + 1, j + 1);
                        }
                        ans.add(b);
                        i++;
                    }
                }
                out.println(ans.size());
                for (int[] a : ans) {
                    for (int k = 0; k < 5; k++) {
                        out.print(++a[k] + " ");
                    }
                    out.println(++a[5]);
                }
            }

        }

        void rev(char[][] board, int i, int j) {
            if (board[i][j] == '1') {
                board[i][j] = '0';
                return;
            }
            board[i][j] = '1';
        }

        int[][] four(char[][] board, int i, int j) {
            int[][] b = new int[4][6];
            int c = 0;
            for (int ai = 0; ai <= 1; ai++) {
                for (int aj = 0; aj <= 1; aj++) {
                    rev(board, i + ai, j + aj);
                    b[0][2 * c] = i + ai;
                    b[0][2 * c + 1] = j + aj;
                    c++;
                    if (c == 3) {
                        break;
                    }
                }
            }
            int[][] next = one(board, i, j);
            b[1] = next[0];
            b[2] = next[1];
            b[3] = next[2];
            return b;
        }

        int[][] one(char[][] board, int i, int j) {
            int[][] b = new int[3][6];
            int c = 0;
            int cnt1 = 0;
            for (int ai = 0; ai <= 1; ai++) {
                for (int aj = 0; aj <= 1; aj++) {
                    if (board[i + ai][j + aj] == '0' && cnt1 < 2) {
                        b[0][2 * c] = i + ai;
                        b[0][2 * c + 1] = j + aj;
                        rev(board, i + ai, j + aj);
                        cnt1++;
                        c++;
                    } else if (board[i + ai][j + aj] == '1') {
                        rev(board, i + ai, j + aj);
                        b[0][2 * c] = i + ai;
                        b[0][2 * c + 1] = j + aj;
                        c++;
                    }
                }
            }
            int[][] next = two(board, i, j);
            b[1] = next[0];
            b[2] = next[1];
            return b;
        }

        int[][] two(char[][] board, int i, int j) {
            int[][] b = new int[2][6];
            int c = 0;
            boolean found = false;
            for (int ai = 0; ai <= 1; ai++) {
                for (int aj = 0; aj <= 1; aj++) {
                    if (board[i + ai][j + aj] == '0') {
                        b[0][2 * c] = i + ai;
                        b[0][2 * c + 1] = j + aj;
                        rev(board, i + ai, j + aj);
                        c++;
                    } else if (board[i + ai][j + aj] == '1' && !found) {
                        rev(board, i + ai, j + aj);
                        b[0][2 * c] = i + ai;
                        b[0][2 * c + 1] = j + aj;
                        c++;
                        found = true;
                    }
                }
            }
            b[1] = three(board, i, j)[0];
            return b;
        }

        int[][] three(char[][] board, int i, int j) {
            int[] b = new int[6];
            int c = 0;
            for (int ai = 0; ai <= 1; ai++) {
                for (int aj = 0; aj <= 1; aj++) {
                    if (board[i + ai][j + aj] == '1') {
                        b[2 * c] = i + ai;
                        b[2 * c + 1] = j + aj;
                        rev(board, i + ai, j + aj);
                        c++;
                    }
                }
            }
            return new int[][]{b};
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}