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.io.PrintStream;
import java.util.Arrays;
import java.nio.CharBuffer;
import java.io.IOException;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.nio.charset.Charset;
import java.io.Writer;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class A1BinaryTableEasyVersion {
        public void solve(int testNumber, LightScanner2 in, LightWriter2 out) {
            int testCases = in.ints();
            for (int testCase = 1; testCase <= testCases; testCase++) {
                int n = in.ints(), m = in.ints();
                A1BinaryTableEasyVersion.Board b;
                b = new A1BinaryTableEasyVersion.Board(in.chars(n));
                for (int i = 0; i < n - 2; i++) {
                    for (int j = 0; j < m - 1; j++) {
                        if (b.s[i][j] == '1') {
                            b.operate(i, j, i + 1, j, i, j + 1);
                        }
                    }
                    if (b.s[i][m - 1] == '1') {
                        b.operate(i, m - 1, i + 1, m - 2, i + 1, m - 1);
                    }
                }
                for (int i = 0; i < m - 2; i++) {
                    if (b.s[n - 2][i] == '0' && b.s[n - 1][i] == '0') {
                    } else if (b.s[n - 2][i] == '1' && b.s[n - 1][i] == '0') {
                        b.operate(n - 2, i, n - 1, i + 1, n - 2, i + 1);
                    } else if (b.s[n - 2][i] == '0' && b.s[n - 1][i] == '1') {
                        b.operate(n - 1, i, n - 1, i + 1, n - 2, i + 1);
                    } else {
                        b.operate(n - 2, i, n - 1, i, n - 2, i + 1);
                    }
                }

                int len0 = 0, len1 = 0;
                int[] xs0 = new int[4], ys0 = new int[4];
                int[] xs1 = new int[4], ys1 = new int[4];
                Arrays.fill(xs0, -1);
                Arrays.fill(ys0, -1);
                Arrays.fill(xs1, -1);
                Arrays.fill(ys1, -1);
                for (int i = n - 2; i < n; i++) {
                    for (int j = m - 2; j < m; j++) {
                        if (b.s[i][j] == '1') {
                            xs1[len1] = j;
                            ys1[len1] = i;
                            len1++;
                        } else {
                            xs0[len0] = j;
                            ys0[len0] = i;
                            len0++;
                        }
                    }
                }
                //System.out.println(Arrays.toString(xs0));
                //System.out.println(Arrays.toString(ys0));
                //System.out.println(Arrays.toString(xs1));
                //System.out.println(Arrays.toString(ys1));
                if (len1 == 4) {
                    //System.out.println("==4==");
                    b.operate(ys1[1], xs1[1], ys1[2], xs1[2], ys1[3], xs1[3]);
                    ys0[0] = ys1[1];
                    xs0[0] = xs1[1];
                    ys0[1] = ys1[2];
                    xs0[1] = xs1[2];
                    ys0[2] = ys1[3];
                    xs0[2] = xs1[3];
                    len1 -= 3;
                }
                if (len1 == 1) {
                    //System.out.println("==1==");
                    b.operate(ys1[0], xs1[0], ys0[1], xs0[1], ys0[2], xs0[2]);
                    int ty = ys1[0], tx = xs1[0];
                    ys1[0] = ys0[1];
                    xs1[0] = xs0[1];
                    ys1[1] = ys0[2];
                    xs1[1] = xs0[2];
                    ys0[1] = ty;
                    xs0[1] = tx;
                    len1 += 1;
                }
                if (len1 == 2) {
                    //System.out.println("==2==");
                    b.operate(ys1[1], xs1[1], ys0[0], xs0[0], ys0[1], xs0[1]);
                    int ty = ys1[1], tx = xs1[1];
                    ys1[1] = ys0[0];
                    xs1[1] = xs0[0];
                    ys1[2] = ys0[1];
                    xs1[2] = xs0[1];
                    ys0[0] = ty;
                    xs0[0] = tx;
                    len1 += 1;
                }
                if (len1 == 3) {
                    //System.out.println("==3==");
                    b.operate(ys1[0], xs1[0], ys1[1], xs1[1], ys1[2], xs1[2]);
                }


                b.assertion();
                out.ans(b.ans.size()).ln();
                for (A1BinaryTableEasyVersion.Operation op : b.ans) {
                    out.ans(op.y0 + 1).ans(op.x0 + 1);
                    out.ans(op.y1 + 1).ans(op.x1 + 1);
                    out.ans(op.y2 + 1).ans(op.x2 + 1).ln();
                }
            }
        }

        private static class Board {
            final char[][] s;
            final List<A1BinaryTableEasyVersion.Operation> ans = new ArrayList<>();

            Board(char[][] s) {
                this.s = s;
            }

            void operate(int y0, int x0, int y1, int x1, int y2, int x2) {
                //System.out.println("("+x0+","+y0+"), "+"("+x1+","+y1+"), "+"("+x2+","+y2+"), ");
                s[y0][x0] ^= 1;
                s[y1][x1] ^= 1;
                s[y2][x2] ^= 1;
                ans.add(new A1BinaryTableEasyVersion.Operation(x0, y0, x1, y1, x2, y2));
                //print();
            }

            void print() {
                System.out.println("======");
                for (int i = 0; i < s.length; i++) {
                    System.out.println(String.valueOf(s[i]));
                }
            }

            void assertion() {
                for (char[] e : s) {
                    for (char c : e)
                        if (c == '1') {
                            print();
                            throw new RuntimeException();
                        }
                }
            }

        }

        private static class Operation {
            int x0;
            int y0;
            int x1;
            int y1;
            int x2;
            int y2;

            Operation(int x0, int y0, int x1, int y1, int x2, int y2) {
                this.x0 = x0;
                this.y0 = y0;
                this.x1 = x1;
                this.y1 = y1;
                this.x2 = x2;
                this.y2 = y2;
            }

        }

    }

    static class LightScanner2 extends LightScannerAdapter {
        private static final int BUF_SIZE = 16 * 1024;
        private final InputStream stream;
        private final StringBuilder builder = new StringBuilder();
        private final byte[] buf = new byte[BUF_SIZE];
        private int ptr;
        private int len;

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

        private int read() {
            if (ptr < len) return buf[ptr++];
            reload();
            if (len == -1) return -1;
            return buf[ptr++];
        }

        private void reload() {
            try {
                ptr = 0;
                len = stream.read(buf);
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

        private void load(int n) {
            if (ptr + n <= len) return;
            System.arraycopy(buf, ptr, buf, 0, len - ptr);
            len -= ptr;
            ptr = 0;
            try {
                int r = stream.read(buf, len, BUF_SIZE - len);
                if (r == -1) return;
                len += r;
                if (len != BUF_SIZE) buf[len] = '\n';
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

        private void skip() {
            while (len != -1) {
                while (ptr < len && isTokenSeparator(buf[ptr])) ptr++;
                if (ptr < len) return;
                reload();
            }
            throw new NoSuchElementException("EOF");
        }

        private void loadToken() {
            builder.setLength(0);
            skip();
            for (int b = read(); !isTokenSeparator(b); b = read()) {
                builder.appendCodePoint(b);
            }
        }

        public String string() {
            loadToken();
            return builder.toString();
        }

        public char[] chars() {
            loadToken();
            char[] res = new char[builder.length()];
            builder.getChars(0, builder.length(), res, 0);
            return res;
        }

        public int ints() {
            skip();
            load(12);
            int b = buf[ptr++];
            boolean negate;
            if (b == '-') {
                negate = true;
                b = buf[ptr++];
            } else negate = false;
            int x = 0;
            for (; !isTokenSeparator(b); b = buf[ptr++]) {
                if ('0' <= b && b <= '9') x = x * 10 + b - '0';
                else throw new NumberFormatException("Unexpected character '" + ((char) b) + "'");
            }
            return negate ? -x : x;
        }

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

        private static boolean isTokenSeparator(int b) {
            return b < 33 || 126 < b;
        }

    }

    static class LightWriter2 implements AutoCloseable {
        private static final int BUF_SIZE = 16 * 1024;
        private final OutputStream out;
        private final byte[] buf = new byte[BUF_SIZE];
        private int ptr;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter2(OutputStream out) {
            this.out = out;
        }

        public LightWriter2(Writer out) {
            this.out = new LightWriter2.WriterOutputStream(out);
        }

        private void allocate(int n) {
            if (ptr + n <= BUF_SIZE) return;
            try {
                out.write(buf, 0, ptr);
                ptr = 0;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            if (BUF_SIZE < n) throw new IllegalArgumentException("Internal buffer exceeded");
        }

        public void close() {
            try {
                out.write(buf, 0, ptr);
                ptr = 0;
                out.flush();
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

        private static int countDigits(int l) {
            if (l >= 1000000000L) return 10;
            if (l >= 100000000L) return 9;
            if (l >= 10000000L) return 8;
            if (l >= 1000000L) return 7;
            if (l >= 100000L) return 6;
            if (l >= 10000L) return 5;
            if (l >= 1000L) return 4;
            if (l >= 100L) return 3;
            if (l >= 10L) return 2;
            return 1;
        }

        public LightWriter2 ans(int x) {
            allocate(12);
            if (!breaked) buf[ptr++] = ' ';
            breaked = false;

            if (x < 0) {
                buf[ptr++] = '-';
                x = -x;
            }
            int n = countDigits(x);
            for (int i = ptr + n - 1; ptr <= i; i--) {
                buf[i] = (byte) (x % 10 + '0');
                x /= 10;
            }
            ptr += n;

            return this;
        }

        public LightWriter2 ln() {
            allocate(1);
            buf[ptr++] = '\n';
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        private static class WriterOutputStream extends OutputStream {
            final Writer writer;
            final CharsetDecoder decoder;

            WriterOutputStream(Writer writer) {
                this.writer = writer;
                this.decoder = StandardCharsets.UTF_8.newDecoder();
            }

            public void write(int b) throws IOException {
                writer.write(b);
            }

            public void write(byte[] b) throws IOException {
                writer.write(decoder.decode(ByteBuffer.wrap(b)).array());
            }

            public void write(byte[] b, int off, int len) throws IOException {
                writer.write(decoder.decode(ByteBuffer.wrap(b, off, len)).array());
            }

            public void flush() throws IOException {
                writer.flush();
            }

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

        }

    }

    static abstract class LightScannerAdapter implements AutoCloseable {
        public abstract String string();

        public char[] chars() {
            return string().toCharArray();
        }

        public final char[][] chars(int h) {
            char[][] res = new char[h][];
            Arrays.setAll(res, ignored -> chars());
            return res;
        }

        public abstract void close();

    }
}