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.BigInteger;
import java.util.*;
import static java.lang.Math.PI;
import static java.lang.System.in;
import static java.lang.System.out;

public class B {
    public static void main(String[] args) throws Exception {   
        Foster sc = new Foster();
        PrintWriter p = new PrintWriter(out);
        int t = sc.nextInt();
        while(t--!=0){
            int n = sc.nextInt();
            int m = sc.nextInt();
            int a[][] = new int[n][m];
            for(int i = 0; i < n; i++){
                char arr[] = sc.next().toCharArray();
                for(int j = 0; j < m; j++){
                    if(arr[j]=='1') a[i][j] = 1;
                    else    a[i][j] = 0;
                }
            }

            ArrayList<ArrayList<Integer>> ans = new ArrayList<>();

            for(int i = 0; i < n-1; i++){
                for(int j = 0; j < m-1; j++){

                    ArrayList<Integer> inThis = new ArrayList<>();
                    int countOne = 0, countZero = 0;
                    for(int x = i; x < i+2; x++){
                        for(int y = j; y < j+2; y++){
                            if(a[x][y] == 0)    countZero++;
                            if(a[x][y] == 1)    countOne++;
                        }
                    }
                    int x1 = i, y1 = j;
                    int x2 = i, y2 = j+1;
                    int x3 = i+1, y3 = j;
                    int x4 = i+1, y4 = j+1;

                    if(countZero==4)    continue;

                    if(countOne==4){
                        inThis = new ArrayList<>();
                        inThis.add(x1);
                        inThis.add(y1);
                        inThis.add(x2);
                        inThis.add(y2);
                        inThis.add(x4);
                        inThis.add(y4);
                        a[x1][y1] = 0;
                        a[x2][y2] = 0;
                        a[x4][y4] = 0;
                        ans.add(inThis);

                        // code for 1
                        inThis = new ArrayList<>();
                        int counter = 0;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 0){
                                    a[x][y] = -1;
                                    inThis.add(x);
                                    inThis.add(y);
                                    counter++;
                                }
                                if(counter == 2)    break;
                            }
                            if(counter == 2)    break;
                        }
                        boolean got = false;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 1){
                                    a[x][y] = -2;
                                    inThis.add(x);
                                    inThis.add(y);
                                    got = true;
                                    break;
                                }
                            }
                            if(got) break;
                        }
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == -2){
                                    a[x][y] = 0;
                                }
                                if(a[x][y] == -1){
                                    a[x][y] = 1;
                                }
                            }
                        }
                        ans.add(inThis);
                        // code for 1

                        // code for 2
                        inThis = new ArrayList<>();
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 0){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -1;
                                }
                            }
                        }
                        got = false;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 1){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -2;
                                    got = true;
                                    break;
                                }
                            }
                            if(got) break;
                        }
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == -1){
                                    a[x][y] = 1;
                                }
                                if(a[x][y] == -2){
                                    a[x][y] = 0;
                                }
                            }
                        }
                        ans.add(inThis);
                        // code for 2
                        
                        // code for 3
                        inThis = new ArrayList<>();
                        if(a[x1][y1]==1){
                            inThis.add(x1);
                            inThis.add(y1);
                        }
                        if(a[x2][y2]==1){
                            inThis.add(x2);
                            inThis.add(y2);
                        }
                        if(a[x3][y3]==1){
                            inThis.add(x3);
                            inThis.add(y3);
                        }
                        if(a[x4][y4]==1){
                            inThis.add(x4);
                            inThis.add(y4);
                        }
                        a[x1][y1] = 0;
                        a[x2][y2] = 0;
                        a[x3][y3] = 0;
                        a[x4][y4] = 0;
                        ans.add(inThis);
                        // code for 3
                        continue;
                    }

                    if(countOne==3){    //choose those three
                        if(a[x1][y1]==1){
                            inThis.add(x1);
                            inThis.add(y1);
                        }
                        if(a[x2][y2]==1){
                            inThis.add(x2);
                            inThis.add(y2);
                        }
                        if(a[x3][y3]==1){
                            inThis.add(x3);
                            inThis.add(y3);
                        }
                        if(a[x4][y4]==1){
                            inThis.add(x4);
                            inThis.add(y4);
                        }
                        a[x1][y1] = 0;
                        a[x2][y2] = 0;
                        a[x3][y3] = 0;
                        a[x4][y4] = 0;
                        ans.add(inThis);
                        continue;
                    }

                    if(countOne==2){        // choose 2 zeros and 1 one
                        inThis = new ArrayList<>();
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 0){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -1;
                                }
                            }
                        }
                        boolean got = false;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 1){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -2;
                                    got = true;
                                    break;
                                }
                            }
                            if(got) break;
                        }
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == -1){
                                    a[x][y] = 1;
                                }
                                if(a[x][y] == -2){
                                    a[x][y] = 0;
                                }
                            }
                        }
                        ans.add(inThis);

                        // code for 3
                        inThis = new ArrayList<>();
                        if(a[x1][y1]==1){
                            inThis.add(x1);
                            inThis.add(y1);
                        }
                        if(a[x2][y2]==1){
                            inThis.add(x2);
                            inThis.add(y2);
                        }
                        if(a[x3][y3]==1){
                            inThis.add(x3);
                            inThis.add(y3);
                        }
                        if(a[x4][y4]==1){
                            inThis.add(x4);
                            inThis.add(y4);
                        }
                        a[x1][y1] = 0;
                        a[x2][y2] = 0;
                        a[x3][y3] = 0;
                        a[x4][y4] = 0;
                        ans.add(inThis);
                        // code for 3
                        continue;
                    }

                    if(countOne==1){
                        inThis = new ArrayList<>();
                        int counter = 0;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 0){
                                    a[x][y] = -1;
                                    inThis.add(x);
                                    inThis.add(y);
                                    counter++;
                                }
                                if(counter == 2)    break;
                            }
                            if(counter == 2)    break;
                        }
                        boolean got = false;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 1){
                                    a[x][y] = -2;
                                    inThis.add(x);
                                    inThis.add(y);
                                    got = true;
                                    break;
                                }
                            }
                            if(got) break;
                        }
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == -2){
                                    a[x][y] = 0;
                                }
                                if(a[x][y] == -1){
                                    a[x][y] = 1;
                                }
                            }
                        }
                        ans.add(inThis);

                        // code for 2
                        inThis = new ArrayList<>();
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 0){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -1;
                                }
                            }
                        }
                        got = false;
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == 1){
                                    inThis.add(x);
                                    inThis.add(y);
                                    a[x][y] = -2;
                                    got = true;
                                    break;
                                }
                            }
                            if(got) break;
                        }
                        for(int x = i; x < i+2; x++){
                            for(int y = j; y < j+2; y++){
                                if(a[x][y] == -1){
                                    a[x][y] = 1;
                                }
                                if(a[x][y] == -2){
                                    a[x][y] = 0;
                                }
                            }
                        }
                        ans.add(inThis);
                        // code for 2
                        
                        // code for 3
                        inThis = new ArrayList<>();
                        if(a[x1][y1]==1){
                            inThis.add(x1);
                            inThis.add(y1);
                        }
                        if(a[x2][y2]==1){
                            inThis.add(x2);
                            inThis.add(y2);
                        }
                        if(a[x3][y3]==1){
                            inThis.add(x3);
                            inThis.add(y3);
                        }
                        if(a[x4][y4]==1){
                            inThis.add(x4);
                            inThis.add(y4);
                        }
                        a[x1][y1] = 0;
                        a[x2][y2] = 0;
                        a[x3][y3] = 0;
                        a[x4][y4] = 0;
                        ans.add(inThis);
                        // code for 3
                        continue;
                    }
                    // the end
                }
            }

            // for(int i = 0; i < n; i++){
            //     for(int j = 0; j < m; j++){
            //         p.print(a[i][j] + " ");
            //     }
            //     p.println();
            // }
            p.println(ans.size());
            for(int i = 0; i < ans.size(); i++){
                for(int j = 0; j < ans.get(i).size(); j++){
                    int now_one = ans.get(i).get(j);
                    p.print((now_one+1) + " ");
                }
                p.println();
            }
        }
        p.close();
    }

    static int[] sort(int a[]){
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i : a){
            arr.add(i);
        }
        Collections.sort(arr);
        for(int i = 0; i < arr.size(); i++){
            a[i] = arr.get(i);
        }
        return a;
    }
/* 
    1. Take a 2x2 grid and apply at max 4 operations it
    2. Got the solution
    3. Just need to implement
*/    
/*
1. Check overflow in pow function or in general
2. Check indices of read array function
3. Think of an easier solution because the problems you solve are always easy
4. Check iterator of loop
5. If still doesn't work, then jump from the 729th floor 'coz "beta tumse na ho paayega"

    Move to top!!
*/
    static class Foster {
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } 
                catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        int[] intArray(int n) {                   // Check indices
            int arr[] = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        long[] longArray(int n) {                 // Check indices
            long arr[] = new long[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        int[] getBits(int n) {                   //in Reverse Order
            int a[] = new int[31];
            for(int i = 0; i < 31; i++) {
                if(((1<<i) & n) != 0)
                    a[i] = 1;
            }
            return a;
        }
        static String reverse(String s){
            String temp = "";
            for(int i = s.length()-1; i >= 0; i--){
                temp += s.charAt(i);
            }
            return temp;
        }
        static long pow(long... a) {
            long mod = Long.MAX_VALUE;
            if(a.length == 3)   mod = a[2];
            long res = 1;
            while(a[1] > 0) {
                if((a[1] & 1) == 1)
                    res = (res * a[0]) % mod;
                a[1] /= 2;
                a[0] = (a[0] * a[0]) % mod;
            }
            return res;
        }
        static void print(Object... o) {
            for(Object next : o) {
                System.err.print(next + " ");
            }
        }
        static void println(Object... o) {
            for(Object next : o) {
                System.err.print(next + " ");
            }
            System.err.println();
        }
        static void watch(Object...a) throws Exception {
            int i = 1;
            for (Object o: a) {
                boolean found = false;
                if (o.getClass().isArray()) {
                    String type = o.getClass().getName().toString();
                    switch (type) {
                        case "[I": {
                            int[] test = (int[]) o;
                            println(i + " : " + Arrays.toString(test));
                            break;
                        }
                        case "[[I": {
                            int[][] obj = (int[][]) o;
                            println(i + " : " + Arrays.deepToString(obj));
                            break;
                        }
                        case "[J": {
                            long[] obj = (long[]) o;
                            println(i + " : " + Arrays.toString(obj));
                            break;
                        }
                        case "[[J": {
                            long[][] obj = (long[][]) o;
                            println(i + " : " + Arrays.deepToString(obj));
                            break;
                        }
                        case "[D": {
                            double[] obj = (double[]) o;
                            println(i + " : " + Arrays.toString(obj));
                            break;
                        }
                        case "[[D": {
                            double[][] obj = (double[][]) o;
                            println(i + " : " + Arrays.deepToString(obj));
                            break;
                        }
                        case "[Ljava.lang.String": {
                            String[] obj = (String[]) o;
                            println(i + " : " + Arrays.toString(obj));
                            break;
                        }
                        case "[[Ljava.lang.String": {
                            String[][] obj = (String[][]) o;
                            println(i + " : " + Arrays.deepToString(obj));
                            break;
                        }
                        case "[C": {
                            char[] obj = (char[]) o;
                            println(i + " : " + Arrays.toString(obj));
                            break;
                        }
                        case "[[C": {
                            char[][] obj = (char[][]) o;
                            println(i + " : " + Arrays.deepToString(obj));
                            break;
                        }
                        default: {
                            println(i + " : type not identified");
                            break;
                        }
                    }
                    found = true;
                }
                if (o.getClass() == ArrayList.class) {
                    println(i + " : LIST = " + o);
                    found = true;
                }
                if (o.getClass() == TreeSet.class) {
                    println(i + " : SET = " + o);
                    found = true;
                }
                if (o.getClass() == TreeMap.class) {
                    println(i + " : MAP = " + o);
                    found = true;
                }
                if (o.getClass() == HashMap.class) {
                    println(i + " : MAP = " + o);
                    found = true;
                }
                if (o.getClass() == LinkedList.class) {
                    println(i + " : LIST = " + o);
                    found = true;
                }
                if (o.getClass() == PriorityQueue.class) {
                    println(i + " : PQ = " + o);
                    found = true;
                }
                if (!found) {
                    println(i + " = " + o);
                }
                i++;
            }
        }
    }
}