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

public class Main {
    void flip(boolean[][] a, int i, int j, List<List<Integer>> ans) {
        List<Integer> tmp = new ArrayList<>();
        a[i][j] = !a[i][j];
        tmp.add(i);
        tmp.add(j);
        a[i + 1][j] = !a[i + 1][j];
        tmp.add(i + 1);
        tmp.add(j);
        a[i][j + 1] = !a[i][j + 1];
        tmp.add(i);
        tmp.add(j + 1);
        ans.add(tmp);
    }

    void flipRev(boolean[][] a, int i, int j, List<List<Integer>> ans) {
        List<Integer> tmp = new ArrayList<>();
        a[i][j] = !a[i][j];
        tmp.add(i);
        tmp.add(j);
        a[i + 1][j - 1] = !a[i + 1][j - 1];
        tmp.add(i + 1);
        tmp.add(j - 1);
        a[i + 1][j] = !a[i + 1][j];
        tmp.add(i + 1);
        tmp.add(j);
        ans.add(tmp);
    }

    void flipTop(boolean[][] a, int i, int j, List<List<Integer>> ans) {
        List<Integer> tmp = new ArrayList<>();
        a[i][j] = !a[i][j];
        tmp.add(i);
        tmp.add(j);
        a[i - 1][j + 1] = !a[i - 1][j + 1];
        tmp.add(i - 1);
        tmp.add(j + 1);
        a[i][j + 1] = !a[i][j + 1];
        tmp.add(i);
        tmp.add(j + 1);
        ans.add(tmp);
    }

    void flipEnd(boolean[][] a, int c1, int c0, List<List<Integer>> ans) {
        List<Integer> tmp = new ArrayList<>();
        int n = a.length;
        int m = a[0].length;
        if (a[n - 2][m - 2] && c1 > 0) {
            a[n - 2][m - 2] = !a[n - 2][m - 2];
            tmp.add(n-2);
            tmp.add(m-2);
            c1--;
        } else if (!a[n - 2][m - 2] && c0 > 0) {
            a[n - 2][m - 2] = !a[n - 2][m - 2];
            tmp.add(n-2);
            tmp.add(m-2);
            c0--;
        }
        if (a[n - 1][m - 2] && c1 > 0) {
            a[n - 1][m - 2] = !a[n - 1][m - 2];
            tmp.add(n-1);
            tmp.add(m-2);
            c1--;
        } else if (!a[n - 1][m - 2] && c0 > 0) {
            a[n - 1][m - 2] = !a[n - 1][m - 2];
            tmp.add(n-1);
            tmp.add(m-2);
            c0--;
        }
        if (a[n - 2][m - 1] && c1 > 0) {
            a[n - 2][m - 1] = !a[n - 2][m - 1];
            tmp.add(n-2);
            tmp.add(m-1);
            c1--;
        } else if (!a[n - 2][m - 1] && c0 > 0) {
            a[n - 2][m - 1] = !a[n - 2][m - 1];
            tmp.add(n-2);
            tmp.add(m-1);
            c0--;
        }
        if (a[n - 1][m - 1] && c1 > 0) {
            a[n - 1][m - 1] = !a[n - 1][m - 1];
            tmp.add(n-1);
            tmp.add(m-1);
            c1--;
        } else if (!a[n - 1][m - 1] && c0 > 0) {
            a[n - 1][m - 1] = !a[n - 1][m - 1];
            tmp.add(n-1);
            tmp.add(m-1);
            c0--;
        }
        if (c1 != 0 || c0 != 0) throw new RuntimeException();
        ans.add(tmp);
    }

    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        boolean[][] a = new boolean[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLineBools();
        }
        List<List<Integer>> ans = new ArrayList<>();
        for (int i = 0; i < n - 2; i++) {
            for (int j = 0; j < m - 1; j++) {
                if (a[i][j]) flip(a, i, j, ans);
            }
            if (a[i][m - 1]) flipRev(a, i, m - 1, ans);
        }
        for (int j = 0; j < m - 2; j++) {
            if (a[n - 2][j]) flip(a, n - 2, j, ans);
            if (a[n - 1][j]) flipTop(a, n - 1, j, ans);
        }
        while (true) {
            int count = 0;
            if (a[n - 2][m - 2]) count++;
            if (a[n - 1][m - 2]) count++;
            if (a[n - 2][m - 1]) count++;
            if (a[n - 1][m - 1]) count++;
            if (count == 4) {
                flipEnd(a, 3, 0, ans);
            }
            if (count == 3) {
                flipEnd(a, 3, 0, ans);
            }
            if (count == 2) {
                flipEnd(a, 1, 2, ans);
            }
            if (count == 1) {
                flipEnd(a, 1, 2, ans);
            }
            if (count == 0) {
                break;
            }

        }
//        for (int i = 0; i < n; i++) {
//            for (int j = 0; j < m; j++) {
//                out.print(a[i][j] ? '1' : '0');
//            }
//            out.println();
//        }

        out.println(ans.size());
        for (List<Integer> list : ans) {
            for (int i = 0; i < 6; i++) {
                out.print((list.get(i)+1)+" ");
            }
            out.println();
        }
    }

    static final boolean MULTI_TEST = true;

    // --------------------------------------------------------------------------------------------------------------
    // --------------------------------------------------HELPER------------------------------------------------------
    // --------------------------------------------------------------------------------------------------------------


    void run() {
        if (MULTI_TEST) {
            int t = in.nextInt();
            for (int i = 0; i < t; i++) {
                solve();
            }
        } else {
            solve();
        }
    }

    // --------------------ALGORITHM-------------------------

    static int MOD = 1000000007;

    public void sort(int[] arr) {
        List<Integer> tmp = Arrays.stream(arr).boxed().sorted().collect(Collectors.toList());
        for (int i = 0; i < arr.length; i++) {
            arr[i] = tmp.get(i);
        }
    }

    public void sortRev(int[] arr) {
        List<Integer> tmp = Arrays.stream(arr).boxed().sorted(Comparator.comparing((Integer x) -> x).reversed())
                .collect(Collectors.toList());
        for (int i = 0; i < arr.length; i++) {
            arr[i] = tmp.get(i);
        }
    }

    // --------------------SCANNER-------------------------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner(String fileName) {
            if (fileName != null) {
                try {
                    br = new BufferedReader(new FileReader(fileName));
                } catch (FileNotFoundException e) {
                    throw new RuntimeException(e);
                }
            } else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextInts(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        boolean[] nextLineBools() {
            String line = nextLine();
            int n = line.length();
            boolean[] booleans = new boolean[n];
            for (int i = 0; i < n; i++) {
                booleans[i] = line.charAt(i) == '1';
            }
            return booleans;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongs(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            try {
                String line = br.readLine();
                if (line == null) {
                    throw new RuntimeException("empty line");
                }
                return line;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }

    // --------------------WRITER-------------------------
    public static class MyWriter extends PrintWriter {

        public static MyWriter of(String fileName) {
            if (fileName != null) {
                try {
                    return new MyWriter(new FileWriter(fileName));
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } else {
                return new MyWriter(new BufferedOutputStream(System.out));
            }
        }

        public MyWriter(FileWriter fileWriter) {
            super(fileWriter);
        }

        public MyWriter(OutputStream out) {
            super(out);
        }

        void println(int[] arr) {
            String line = Arrays.stream(arr).mapToObj(String::valueOf).collect(Collectors.joining(" "));
            println(line);
        }

    }

    // -----------------------BENCHMARK-------------------------
    public static class Benchmark {
        long time;

        public void reset() {
            time = System.currentTimeMillis();
        }

        public long calc() {
            long curTime = System.currentTimeMillis();
            long tmp = curTime - time;
            time = curTime;
            return tmp;
        }

    }


    // --------------------MAIN-------------------------

    public MyScanner in;
    public MyWriter out;
    public Benchmark bm;

    /**
     * add `-Xss256m` to increase stack size
     */
    public static void main(String[] args) {
        boolean local = args.length > 0;
        String input = local ? "src/input.txt" : null;

        Main m = new Main();
        m.in = new MyScanner(input);
        m.out = MyWriter.of(null);
        m.bm = new Benchmark();
        m.run();
        m.out.close();
    }
}