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.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "khokharnikunj8", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            A1BinaryTableEasyVersion solver = new A1BinaryTableEasyVersion();
            int testCount = Integer.parseInt(in.next());
            for (int i = 1; i <= testCount; i++)
                solver.solve(i, in, out);
            out.close();
        }
    }

    static class A1BinaryTableEasyVersion {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int m = in.readInt();
            char[][] ar = new char[n][];
            char[][] br = new char[n][];
            for (int i = 0; i < n; i++) {
                ar[i] = in.readString().toCharArray();
                br[i] = Arrays.copyOf(ar[i], m);
            }
            int zero = 0;
            int one = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (ar[i][j] == '0') zero++;
                    else one++;
                }
            }
            List<int[]> res = new ArrayList<>();
            char highest = '0';
            for (int i = 0; i < n - 1; i++) {
                for (int j = 0; j < m - 1; j++) {
                    if (ar[i][j] != highest) {
                        if (ar[i][j + 1] == highest) {
                            ar[i][j] = (char) ('0' + (1 - (ar[i][j] - '0')));
                            ar[i + 1][j] = (char) ('0' + (1 - (ar[i + 1][j] - '0')));
                            ar[i + 1][j + 1] = (char) ('0' + (1 - (ar[i + 1][j + 1] - '0')));
                            res.add(new int[]{i + 1, j + 1, i + 2, j + 1, i + 2, j + 2});
                        } else {
                            ar[i][j] = (char) ('0' + (1 - (ar[i][j] - '0')));
                            ar[i][j + 1] = (char) ('0' + (1 - (ar[i][j + 1] - '0')));
                            ar[i + 1][j] = (char) ('0' + (1 - (ar[i + 1][j] - '0')));
                            res.add(new int[]{i + 1, j + 1, i + 1, j + 2, i + 2, j + 1});
                        }
                    }
                }
            }
            for (int i = 0; i < n - 1; i += 2) {
                if (ar[i][m - 1] == highest && ar[i + 1][m - 1] == highest) {

                } else if (ar[i][m - 1] != highest && ar[i + 1][m - 1] == highest) {
                    res.add(new int[]{i + 1, m, i + 2, m, i + 2, m - 1});
                    res.add(new int[]{i + 1, m, i + 1, m - 1, i + 2, m - 1});
                    res.add(new int[]{i + 1, m, i + 1, m - 1, i + 2, m});
                } else if (ar[i][m - 1] == highest && ar[i + 1][m - 1] != highest) {
                    res.add(new int[]{i + 2, m, i + 1, m, i + 2, m - 1});
                    res.add(new int[]{i + 2, m, i + 1, m - 1, i + 2, m - 1});
                    res.add(new int[]{i + 2, m, i + 1, m - 1, i + 1, m});
                } else {
                    res.add(new int[]{i + 1, m - 1, i + 2, m - 1, i + 1, m});
                    res.add(new int[]{i + 1, m - 1, i + 2, m - 1, i + 2, m});
                }
                ar[i][m - 1] = highest;
                ar[i + 1][m - 1] = highest;
            }

            for (int i = 0; i < n - 1; i += 2) {
                if (ar[i][m - 1] == highest && ar[i + 1][m - 1] == highest) {

                } else if (ar[i][m - 1] != highest && ar[i + 1][m - 1] == highest) {
                    res.add(new int[]{i + 1, m, i + 2, m, i + 2, m - 1});
                    res.add(new int[]{i + 1, m, i + 1, m - 1, i + 2, m - 1});
                    res.add(new int[]{i + 1, m, i + 1, m - 1, i + 2, m});
                } else if (ar[i][m - 1] == highest && ar[i + 1][m - 1] != highest) {
                    res.add(new int[]{i + 2, m, i + 1, m, i + 2, m - 1});
                    res.add(new int[]{i + 2, m, i + 1, m - 1, i + 2, m - 1});
                    res.add(new int[]{i + 2, m, i + 1, m - 1, i + 1, m});
                } else {
                    res.add(new int[]{i + 1, m - 1, i + 2, m - 1, i + 1, m});
                    res.add(new int[]{i + 1, m - 1, i + 2, m - 1, i + 2, m});
                }
                ar[i][m - 1] = highest;
                ar[i + 1][m - 1] = highest;
            }


            for (int j = 0; j < m - 1; j += 2) {
                if (ar[n - 1][j] == highest && ar[n - 1][j + 1] == highest) {

                } else if (ar[n - 1][j] != highest && ar[n - 1][j + 1] == highest) {
                    res.add(new int[]{n, j + 1, n, j + 2, n - 1, j + 2});
                    res.add(new int[]{n, j + 1, n - 1, j + 1, n - 1, j + 2});
                    res.add(new int[]{n, j + 1, n - 1, j + 1, n, j + 2});
                } else if (ar[n - 1][j] == highest && ar[n - 1][j + 1] != highest) {
                    res.add(new int[]{n, j + 2, n, j + 1, n - 1, j + 2});
                    res.add(new int[]{n, j + 2, n - 1, j + 1, n - 1, j + 2});
                    res.add(new int[]{n, j + 2, n - 1, j + 1, n, j + 1});
                } else {
                    res.add(new int[]{n - 1, j + 1, n - 1, j + 2, n, j + 1});
                    res.add(new int[]{n - 1, j + 1, n - 1, j + 2, n, j + 2});
                }
                ar[n - 1][j] = highest;
                ar[n - 1][j + 1] = highest;
            }

            List<int[]>[] L = new ArrayList[2];
            for (int i = 0; i < 2; i++) L[i] = new ArrayList<>();
            if (ar[n - 1][m - 1] == highest) L[0].add(new int[]{n, m});
            else L[1].add(new int[]{n, m});
            if (ar[n - 2][m - 1] == highest) L[0].add(new int[]{n - 1, m});
            else L[1].add(new int[]{n - 1, m});
            if (ar[n - 1][m - 2] == highest) L[0].add(new int[]{n, m - 1});
            else L[1].add(new int[]{n, m - 1});
            if (ar[n - 2][m - 2] == highest) L[0].add(new int[]{n - 1, m - 1});
            else L[1].add(new int[]{n - 1, m - 1});

            if (L[1].size() == 1) {
                res.add(new int[]{L[1].get(0)[0], L[1].get(0)[1], L[0].get(0)[0], L[0].get(0)[1], L[0].get(1)[0], L[0].get(1)[1]});
                res.add(new int[]{L[1].get(0)[0], L[1].get(0)[1], L[0].get(2)[0], L[0].get(2)[1], L[0].get(0)[0], L[0].get(0)[1]});
                res.add(new int[]{L[1].get(0)[0], L[1].get(0)[1], L[0].get(2)[0], L[0].get(2)[1], L[0].get(1)[0], L[0].get(1)[1]});
            } else if (L[1].size() == 2) {
                res.add(new int[]{L[0].get(0)[0], L[0].get(0)[1], L[0].get(1)[0], L[0].get(1)[1], L[1].get(0)[0], L[1].get(0)[1]});
                res.add(new int[]{L[0].get(0)[0], L[0].get(0)[1], L[0].get(1)[0], L[0].get(1)[1], L[1].get(1)[0], L[1].get(1)[1]});
            } else if (L[1].size() == 3) {
                res.add(new int[]{L[0].get(0)[0], L[0].get(0)[1], L[0].get(1)[0], L[0].get(1)[1], L[0].get(2)[0], L[0].get(2)[1]});
            } else if (L[1].size() == 4) {
                throw new RuntimeException("Not possible");
            }

            out.println(res.size());
            for (int[] t : res) {
                for (int j : t) out.append(j + " ");
                out.println();
            }
            for (int[] t : res) {
                for (int i = 0; i < 6; i += 2) {
                    int x = t[i] - 1;
                    int y = t[i + 1] - 1;
                    br[x][y] = (char) ('0' + (1 - (br[x][y] - '0')));
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (br[i][j] != highest) throw new RuntimeException();
                }
            }
//        out.println(n * m);
//        out.println(res.size());
        }

    }

    static class FastInput {
        private final InputStream is;
        private final StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private final byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public String next() {
            return readString();
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private final Writer os;
        private final StringBuilder cache = new StringBuilder(5 << 20);

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(String c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}