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.*;
import java.math.*;
import java.util.*;

public class Codeforce {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in,out);
        out.close();

    }

    static class Solver{
        boolean[] visited;
        ArrayList<Integer>[] adjList;
        final long MOD = 1000000007;
        int[] order;
        int[] orderFreq;


        public void solve(InputReader in, OutputWriter out){
            int t = in.nextInt();
            for(int i = 0; i < t; i++){
                int n = in.nextInt();
                int m = in.nextInt();
                char[][] table = new char[n][m];
                for(int row = 0; row < n; row++){
                    table[row] = in.next().toCharArray();
                }
                ArrayList<int[]> ops = new ArrayList<>();
                for(int row = 0; row < n-1; row+=2){
                    for(int col = 0; col < m-1; col+=2){
                        int num = 0;
                        if(table[row][col] == '1') num++;
                        if(table[row+1][col] == '1') num++;
                        if(table[row][col+1] == '1') num++;
                        if(table[row+1][col+1] == '1') num++;
                        if(num == 4){
                            solve4(table, row, col, ops);
                        }
                        if(num == 3){
                            solve3(table, row, col, ops);
                        }
                        if(num == 2){
                            solve2(table, row, col, ops);
                        }
                        if(num==1){
                            solve1(table, row, col, ops);
                        }
                    }
                }
                for(int row = 0; row < n-1; row+=2){
                    int num = 0;
                    int col = m-2;
                    if(table[row][col] == '1') num++;
                    if(table[row+1][col] == '1') num++;
                    if(table[row][col+1] == '1') num++;
                    if(table[row+1][col+1] == '1') num++;
                    if(num == 4){
                        solve4(table, row, col, ops);
                    }
                    if(num == 3){
                        solve3(table, row, col, ops);
                    }
                    if(num == 2){
                        solve2(table, row, col, ops);
                    }
                    if(num==1){
                        solve1(table, row, col, ops);
                    }
                }
                for(int col = 0; col < m-1; col+=1){
                    int num = 0;
                    int row = n-2;
                    if(table[row][col] == '1') num++;
                    if(table[row+1][col] == '1') num++;
                    if(table[row][col+1] == '1') num++;
                    if(table[row+1][col+1] == '1') num++;
                    if(num == 4){
                        solve4(table, row, col, ops);
                    }
                    if(num == 3){
                        solve3(table, row, col, ops);
                    }
                    if(num == 2){
                        solve2(table, row, col, ops);
                    }
                    if(num==1){
                        solve1(table, row, col, ops);
                    }
                }
                out.printf("%d\n", ops.size());
//                for(int j = 0; j < table.length; j++){
//                    for(int k = 0; k < table[j].length; k++){
//                        System.out.print(table[j][k]);
//                    }
//                    System.out.println();
//                }
                for(int j = 0; j < ops.size(); j++){
                    for(int k = 0; k < 6; k++){
                        out.printf("%d ", ops.get(j)[k]);
                    }
                    out.printf("\n");
                }
            }


        }
        private void solve4(char[][] table, int row, int col, ArrayList<int[]> ops){
            int[] op = new int[6];
            int k = 0;
            int zero = 0;
            if(zero<3){
                table[row][col] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
                zero++;
            }
            if(zero<3){
                table[row+1][col] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
                zero++;
            }
            if(zero<3){
                table[row][col+1] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
                zero++;
            }
            if(zero<3){
                table[row+1][col+1] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
                zero++;
            }
            ops.add(op);
            solve1(table, row, col, ops);
        }
        private void solve3(char[][] table, int row, int col, ArrayList<int[]> ops){
            int[] op = new int[6];
            int k = 0;
            if(table[row][col] == '1'){
                table[row][col] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
            }
            if(table[row+1][col] == '1'){
                table[row+1][col] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
            }
            if(table[row][col+1] == '1'){
                table[row][col+1] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
            }
            if(table[row+1][col+1] == '1'){
                table[row+1][col+1] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
            }
            ops.add(op);
        }
        private void solve2(char[][] table, int row, int col, ArrayList<int[]> ops){
            int[] op = new int[6];
            int k = 0;
            boolean one = false;
            if(table[row][col] == '0'){
                table[row][col] = '1';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
            }
            else if(!one){
                table[row][col] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
                one = true;
            }
            if(table[row+1][col] == '0'){
                table[row+1][col] = '1';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
            }
            else if(!one){
                table[row+1][col] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
                one = true;
            }
            if(table[row][col+1] == '0'){
                table[row][col+1] = '1';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
            }
            else if(!one){
                table[row][col+1] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
                one = true;
            }
            if(table[row+1][col+1] == '0'){
                table[row+1][col+1] = '1';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
            }
            else if(!one){
                table[row+1][col+1] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
                one = true;
            }
            ops.add(op);
            solve3(table, row, col, ops);
        }
        private void solve1(char[][] table, int row, int col, ArrayList<int[]> ops){
            int[] op = new int[6];
            int k = 0;
            int zero = 0;
            if(table[row][col] == '0' && zero<2){
                table[row][col] = '1';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
                zero++;
            }
            else if(table[row][col] == '1'){
                table[row][col] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+1;
                k++;
            }
            if(table[row+1][col] == '0' && zero<2){
                table[row+1][col] = '1';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
                zero++;
            }
            else if(table[row+1][col] == '1'){
                table[row+1][col] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+1;
                k++;
            }
            if(table[row][col+1] == '0' && zero<2){
                table[row][col+1] = '1';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
                zero++;
            }
            else if(table[row][col+1] == '1'){
                table[row][col+1] = '0';
                op[k] = row+1;
                k++;
                op[k] = col+2;
                k++;
            }
            if(table[row+1][col+1] == '0' && zero<2){
                table[row+1][col+1] = '1';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
                zero++;
            }
            else if(table[row+1][col+1] == '1'){
                table[row+1][col+1] = '0';
                op[k] = row+2;
                k++;
                op[k] = col+2;
                k++;
            }
            ops.add(op);
            solve2(table, row, col, ops);
        }
        private void swap(int[] arr, int a, int b){
            int temp = arr[a];
            arr[a] = arr[b];
            arr[b] = temp;
        }
        public int gcd(int a, int b) {
            if (b==0) return a;
            return gcd(b,a%b);
        }
        public long gcd(long a, long b) {
            if (b==0) return a;
            return gcd(b,a%b);
        }


        private void initAdjList(int n){
            adjList = new ArrayList[n];
            visited = new boolean[n];
            for(int i=0;i<n;i++){
                adjList[i] = new ArrayList<>();
            }
        }

        class Edge{
            int weight;
            int node;
            public  Edge(int node, int weight){
                this.node = node;
                this.weight = weight;
            }
        }

        class Pair{
            String name;
            int score;
            public Pair(String name, int score){
                this.name = name;
                this.score = score;
            }
        }

        private int dfs(int u){
            visited[u] = true;
            if(adjList[u].size()<=1){
                return 0;
            }
            int order = Integer.MAX_VALUE;
            for(int v: adjList[u]){
                if(!visited[v]){
                   order = Math.min(dfs(v)+1,order);
                }
            }
            return order;
        }

//        private void bfs(int s) {
//            Queue<Integer> q = new LinkedList<Integer>();
//            q.add(s);
//            visited[s] = true;
//            while(!q.isEmpty()) {
//                int u = q.remove();
//                for(int v: adjList[u]){
//                    if(!visited[v]) {
//                        visited[v] = true;
//                        q.add(v);
//                    }
//                }
//
//            }
//        }

        private  int[] nextAInt(int n, InputReader in){
            int arr[] = new int[n];
            for(int i=0;i<n;i++){
                arr[i]= in.nextInt();
            }
            return arr;
        }

        private  long[] nextALong(int n, InputReader in){
            long arr[] = new long[n];
            for(int i=0;i<n;i++){
                arr[i]= in.nextInt();
            }
            return arr;
        }
    }


    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 16];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public String next() {
            int c;
            while (isSpaceChar(c = this.read())) {
                ;
            }

            StringBuilder result = new StringBuilder();
            result.appendCodePoint(c);

            while (!isSpaceChar(c = this.read())) {
                result.appendCodePoint(c);
            }

            return result.toString();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printf(String format, Object... objects) {
            writer.printf(format, objects);
        }

        public void close() {
            writer.close();
        }

    }


}