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.*;

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int t=Integer.parseInt(bu.readLine());
        while(t-->0)
        {
            String s[]=bu.readLine().split(" ");
            int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);
            int i,j,a[][]=new int[n][m];
            ArrayList<Pair> moves=new ArrayList<>();
            for(i=0;i<n;i++)
            {
                s=bu.readLine().split(" ");
                for(j=0;j<m;j++)
                a[i][j]=s[0].charAt(j)-'0';
            }

            boolean vis[][]=new boolean[n][m];
            for(i=0;i<n-1;i++)
            for(j=0;j<m-1;j++)
            if(i+1==n-1 || j+1==m-1)
            {
                ArrayList<Pair> one=new ArrayList<>(),zero=new ArrayList<>();
                if(a[i][j]==1) one.add(new Pair(i,j));
                else zero.add(new Pair(i,j));
                if(a[i+1][j]==1) one.add(new Pair(i+1,j));
                else zero.add(new Pair(i+1,j));
                if(a[i][j+1]==1) one.add(new Pair(i,j+1));
                else zero.add(new Pair(i,j+1));
                if(a[i+1][j+1]==1) one.add(new Pair(i+1,j+1));
                else zero.add(new Pair(i+1,j+1));
                for(Pair p:zero) vis[p.a][p.b]=true;
                for(Pair p:one) vis[p.a][p.b]=true;
                if(one.size()==0) continue;
                mv=new ArrayList<>();
                int on=one.size();
                if(on==4) step1(zero,one);
                else if(on==3) step4(zero,one);
                else if(on==2) step3(zero,one);
                else step2(zero,one);
                for(Pair p:mv)
                {
                    a[p.a][p.b]=0;
                    moves.add(new Pair(p.a+1,p.b+1));
                }
            }
            else
            {
                if(a[i][j]==0) continue;
                moves.add(new Pair(i+1,j+1));
                if(a[i][j+1]==1)
                {
                    a[i][j+1]=0; moves.add(new Pair(i+1,j+2));
                    if(a[i+1][j]==1) {a[i+1][j]=0; moves.add(new Pair(i+2,j+1));}
                    else {a[i+1][j+1]^=1; moves.add(new Pair(i+2,j+2));}
                }
                else
                {
                    a[i+1][j]^=1; moves.add(new Pair(i+2,j+1));
                    a[i+1][j+1]^=1; moves.add(new Pair(i+2,j+2));
                }
            }
            sb.append(moves.size()/3+"\n");
            for(i=0;i<moves.size();i+=3)
            sb.append(moves.get(i).a+" "+moves.get(i).b+" "+moves.get(i+1).a+" "+moves.get(i+1).b+" "+moves.get(i+2).a+" "+moves.get(i+2).b+"\n");
            //sb.append("\n");
        }
        System.out.print(sb);
    }
    static ArrayList<Pair> mv;
    static class Pair
    {
        int a,b;
        Pair(int u,int v)
        {
            a=u;
            b=v;
        }
    }

    static void step1(ArrayList<Pair> zero,ArrayList<Pair> one)
    {
        ArrayList<Pair> tem=new ArrayList<>();
        for(int i=0;i<4;i++)
        if(i<3)
        {
            zero.add(new Pair(one.get(i).a,one.get(i).b));
            mv.add(new Pair(one.get(i).a,one.get(i).b));
        }
        else tem.add(new Pair(one.get(i).a,one.get(i).b));
        one=tem;
        step2(zero,one);
    }

    static void step2(ArrayList<Pair> zero,ArrayList<Pair> one)
    {
        Pair tem=new Pair(one.get(0).a,one.get(0).b),tem2;
        one=new ArrayList<>();
        for(int i=0;i<2;i++)
        {
            one.add(new Pair(zero.get(i).a,zero.get(i).b));
            mv.add(new Pair(zero.get(i).a,zero.get(i).b));
        }

        tem2=new Pair(zero.get(2).a,zero.get(2).b);
        zero=new ArrayList<>();
        mv.add(new Pair(tem.a,tem.b));
        zero.add(new Pair(tem.a,tem.b));
        zero.add(new Pair(tem2.a,tem2.b));
        step3(zero,one);
    }
    static void step3(ArrayList<Pair> zero,ArrayList<Pair> one)
    {
        ArrayList<Pair> tem=new ArrayList<>();
        for(int i=0;i<2;i++)
        {
            mv.add(new Pair(zero.get(i).a,zero.get(i).b));
            tem.add(new Pair(zero.get(i).a,zero.get(i).b));
        }
        zero=new ArrayList<>();
        for(int i=0;i<2;i++)
        if(i<1) mv.add(new Pair(one.get(i).a,one.get(i).b));
        else tem.add(new Pair(one.get(i).a,one.get(i).b));
        one=new ArrayList<>();
        for(Pair p:tem) one.add(new Pair(p.a,p.b));
        step4(zero,one);
    }
    static void step4(ArrayList<Pair> zero,ArrayList<Pair> one)
    {
        for(Pair p:one)
            mv.add(new Pair(p.a,p.b));
    }
}