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.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    static PrintWriter out;
    static Reader in;
    public static void main(String[] args) throws IOException {
        //in = new Reader(new FileInputStream(args[0])); // for test.
        input_output();
        Main solver = new Main();
        solver.solve();
        out.close(); // remove when testing.
        out.flush(); // remove when testing.
    }
 
    static int INF = (int)1e9;
    static int maxn = (int)2e5+5;
    static int Mod = (int)1e9+7;
    static int n, m, q, t, k;

    void solve() throws IOException{
    	t = in.nextInt();


    	while (t --> 0) {
    		n = in.nextInt();
    		m = in.nextInt();
    		int[][] arr = new int[n][m];
    		String s;
    		for (int i = 0; i < n; i++) {
    			s = in.next();
    			for (int j = 0; j < m; j++) {
    				arr[i][j] = s.charAt(j)-'0';
    			}
    		}
    		ArrayList<Integer> oper = new ArrayList<Integer>();

    		int x = 0;
    		for (int i = 0; i < n-2; i++) {
    			for (int j = 0; j < m; j++) {
    				if (j == m-1) x = j-1;
    				else x = j;
    				if (arr[i][j] == 1) {
    					oper.add(i);
    					oper.add(j);
    					arr[i][j] ^=1;
    					oper.add(i+1);
    					oper.add(x);
    					arr[i+1][x] ^=1;
    					oper.add(i+1);
    					oper.add(x+1);
    					arr[i+1][x+1] ^=1;
    				}
    			}
    		}


    		int cnt = 0;
    		for (int j = 0, i = n-2; j < m-2; j++) {
    			if (arr[i][j] == 1 || arr[i+1][j] == 1) {
    				cnt = 0;
    				if (arr[i][j] == 1) {
    					cnt++;
						oper.add(i);
						oper.add(j);
						arr[i][j]^=1;
    				}
    				if (arr[i+1][j] == 1) {
    					cnt++;
    					oper.add(i+1);
    					oper.add(j);
    					arr[i+1][j]^=1;
    				}
    				if(cnt == 1) {
	    				oper.add(i);
	    				oper.add(j+1);
	    				arr[i][j+1]^=1;
	    				oper.add(i+1);
	    				oper.add(j+1);
	    				arr[i+1][j+1]^=1;
	    			} else if (cnt == 2) {
	    				oper.add(i);
	    				oper.add(j+1);
	    				arr[i][j+1]^=1;
	    			}
    			}
    		}

    		List<Integer> bad = new ArrayList<Integer>();
    		for (int i = n-2; i < n; i++) {
    			for (int j = m-2; j < m; j++) {
    				if (arr[i][j] == 1) {
    					bad.add(i);
    					bad.add(j);
    				}
    			}
    		}

    		if (bad.size()/2 == 3) {
    			for (int i = 0; i < bad.size(); i+=2) {
    				oper.add(bad.get(i));
    				oper.add(bad.get(i+1));
    				arr[bad.get(i)][bad.get(i+1)]^=1;
    			}
    		}
    		if (bad.size()/2 == 4) {
    			int atmp = bad.get(0),
    				btmp = bad.get(1);

    			for (int i = 2; i < bad.size(); i+=2) {
    				oper.add(bad.get(i));
    				oper.add(bad.get(i+1));
    				arr[bad.get(i)][bad.get(i+1)]^=1;
    			}
    			bad.clear();
    			bad.add(atmp);
    			bad.add(btmp);
    		}

    		if (bad.size()/2 == 1) {
    			List<Integer> good = new ArrayList<Integer>();
    			for (int i = n-2; i < n; i++) {
    				for (int j = m-2; j < m; j++) {
    					boolean baad = false;
    					for (int z = 0; z < bad.size(); z+=2) {
    						if (bad.get(z) == i && bad.get(z+1) == j) baad = true;
    					}
    					if (!baad) {
    						good.add(i);
    						good.add(j);
    					}
    				}
    			}

    			oper.add(bad.get(0));
    			oper.add(bad.get(1));
    			arr[bad.get(0)][bad.get(1)] ^=1;
    			oper.add(good.get(0));
    			oper.add(good.get(1));
    			arr[good.get(0)][good.get(1)]^=1;
    			oper.add(good.get(2));
    			oper.add(good.get(3));
    			arr[good.get(2)][good.get(3)] ^=1;
    			bad.clear();
    			for (int i = 0; i < 4; i++) bad.add(good.get(i));
    		}
    		if (bad.size()/2 == 2) {
    			List<Integer> good = new ArrayList<Integer>();
    			for (int i = n-2; i < n; i++) {
    				for (int j = m-2; j < m; j++) {
    					boolean baad = false;
    					for (int z = 0; z < bad.size(); z+=2) {
    						if (bad.get(z) == i && bad.get(z+1) == j) baad = true;
    					}
    					if (!baad) {
    						good.add(i);
    						good.add(j);
    					}
    				}
    			}
    			oper.add(bad.get(0));
    			oper.add(bad.get(1));
    			arr[bad.get(0)][bad.get(1)] ^=1;
    			oper.add(good.get(0));
    			oper.add(good.get(1));
    			arr[good.get(0)][good.get(1)]^=1;
    			oper.add(good.get(2));
    			oper.add(good.get(3));
    			arr[good.get(2)][good.get(3)] ^=1;

    			oper.add(bad.get(2));
    			oper.add(bad.get(3));
    			arr[bad.get(2)][bad.get(3)] ^=1;
    			oper.add(good.get(0));
    			oper.add(good.get(1));
    			arr[good.get(0)][good.get(1)]^=1;
    			oper.add(good.get(2));
    			oper.add(good.get(3));
    			arr[good.get(2)][good.get(3)] ^=1;
    		}

    		out.println(oper.size()/6);
    		for (int i = 0; i < oper.size(); i+=6) {
    			out.print((oper.get(i)+1)+" ");
    			out.print((oper.get(i+1)+1)+" ");
    			out.print((oper.get(i+2)+1)+" ");
    			out.print((oper.get(i+3)+1)+" ");
    			out.print((oper.get(i+4)+1)+" ");
    			out.println((oper.get(i+5)+1));
    		}


    	}

   	}

    //<>


    static class Reader {
 
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
    
        public Reader() {
            this(System.in);
        }
    
        public Reader(InputStream is) {
            mIs = is;
        }
    
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
    
        }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }
    
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
    
        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
    
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
    
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    
        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
    }
    static void input_output() throws IOException {
        File f = new File("in.txt");
        if(f.exists() && !f.isDirectory()) { 
            in = new Reader(new FileInputStream("in.txt"));
        } else in = new Reader();
        f = new File("out.txt");
        if(f.exists() && !f.isDirectory()) {
            out = new PrintWriter(new File("out.txt"));
        } else out = new PrintWriter(System.out);
    }
}