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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;

public class C {
	static class Pair {
		int x1, y1,x2,y2,x3,y3;

		Pair(int x1, int y1,int x2,int y2,int x3,int y3) {
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
			this.x3 = x3;
			this.y3 = y3;
		}

	}

	public static void main(String[] args) throws IOException {

		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = sc.nextInt();
		first: while (t-- != 0) {

			int n = sc.nextInt();
			int m = sc.nextInt();
			char[][] arr = new char[n+1][m+1];
			for(int i=0; i<n; i++) {
				String str = sc.next();
				for(int j=1; j<=m; j++) {
					arr[i+1][j] = str.charAt(j-1);
				}
			}
			ArrayList<Pair> lis = new ArrayList<C.Pair>();
			for(int i=1; i<n; i++) {
				for(int j=1; j<=m; j++) {
					if(arr[i][j] == '0')continue;
					if(j == m) {
						Pair pp = new Pair(i, j, i+1, j, i+1, j-1);
						lis.add(pp);
						arr[i][j] = arr[i][j] == '0'?'1':'0';
						arr[i+1][j] = arr[i+1][j] == '0'?'1':'0';
						arr[i+1][j-1] = arr[i+1][j-1] == '0'?'1':'0';
						
					}
					else {
						Pair pp = new Pair(i, j, i+1, j, i+1, j+1);
						lis.add(pp);
						arr[i][j] = arr[i][j] == '0'?'1':'0';
						arr[i+1][j] = arr[i+1][j] == '0'?'1':'0';
						arr[i+1][j+1] = arr[i+1][j+1] == '0'?'1':'0';
					}
				}
//				print(arr);
			}
		
			
			for(int j=1; j<=m-2; j++) {
				if(arr[n][j] == '1') {
					Pair pp = new Pair(n, j, n-1, j+1, n, j+1);
					lis.add(pp);
					arr[n][j] = arr[n][j] == '0'?'1':'0';
					arr[n-1][j+1] = arr[n-1][j+1] == '0'?'1':'0';
					arr[n][j+1] = arr[n][j+1] == '0'?'1':'0';
				}
				if(arr[n-1][j] == '1') {
					Pair pp = new Pair(n-1, j, n-1, j+1, n, j+1);
					lis.add(pp);
					arr[n-1][j] = arr[n-1][j] == '0'?'1':'0';
					arr[n-1][j+1] = arr[n-1][j+1] == '0'?'1':'0';
					arr[n][j+1] = arr[n][j+1] == '0'?'1':'0';
				}
				
			}
			
			int a1 = n-1,a2 = m-1;
			int b1 = n-1,b2 = m;
			int c1 = n,c2 = m-1;
			int d1 = n,d2 = m;
			int one = 0;
			if(arr[a1][a2] == '1')one++;
			if(arr[b1][b2] == '1')one++;
			if(arr[c1][c2] == '1')one++;
			if(arr[d1][d2] == '1')one++;
			if(one == 0) {
				print(lis);
				continue;
			}
			if(arr[c1][c2] == '1') {
				Pair pp = new Pair(c1, c2, b1, b2, d1, d2);
				lis.add(pp);
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
			}
			if(arr[a1][a2] == '1') {
				Pair pp = new Pair(a1, a2, b1, b2, d1, d2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
			}
			
			if(arr[b1][b2] == '1' && arr[d1][d2] == '1') {
				Pair pp = new Pair(a1, a2, b1, b2, c1, c2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				 pp = new Pair(a1, a2, d1, d2, c1, c2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
			}
			else if(arr[b1][b2] == '1') {
				Pair pp = new Pair(a1, a2, b1, b2, c1, c2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				 pp = new Pair(c1, c2, b1, b2, d1, d2);
				lis.add(pp);
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
				 pp = new Pair(a1, a2, b1, b2, d1, d2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
			}
			else if(arr[d1][d2] == '1') {
				Pair pp = new Pair(a1, a2, d1, d2, c1, c2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				pp = new Pair(a1, a2, b1, b2, d1, d2);
				lis.add(pp);
				arr[a1][a2] = arr[a1][a2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
				pp = new Pair(c1, c2, b1, b2, d1, d2);
				lis.add(pp);
				arr[c1][c2] = arr[c1][c2] == '0'?'1':'0';
				arr[b1][b2] = arr[b1][b2] == '0'?'1':'0';
				arr[d1][d2] = arr[d1][d2] == '0'?'1':'0';
				
			}
			
			
			print(lis);
			
				
			
			
			
//			print(arr);
			
			

		}

	}

	private static void print(ArrayList<Pair> lis) {
		System.out.println(lis.size());
		for(Pair e : lis) {
			System.out.println(e.x1+" "+e.y1+" "+
		e.x2+" "+e.y2+" "+e.x3+" "+e.y3);
		}
		
	}

	private static void print(char[][] arr) {
		for(int i=1; i<arr.length; i++) {
			for(int j=1; j<arr[0].length; j++) {
				System.out.print(arr[i][j]+" ");
			}
			System.out.println();
		}
		
	}

	static void ruffleSort(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
		Arrays.sort(a);
	}

	static void ruffleSort(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
		Arrays.sort(a);
	}

	

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.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());
		}

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

		long[] readArrayLong(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static int ceil(int x, int y) {
		return (x % y == 0 ? x / y : (x / y + 1));
	}

	static long ceil(long x, long y) {
		return (x % y == 0 ? x / y : (x / y + 1));
	}

	static int max(int x, int y) {
		return Math.max(x, y);
	}

	static int min(int x, int y) {
		return Math.min(x, y);
	}

	static long max(long x, long y) {
		return Math.max(x, y);
	}

	static long min(long x, long y) {
		return Math.min(x, y);
	}

	static int min(int a[]) {
		int x = 1_000_000_00_9;
		for (int i = 0; i < a.length; i++)
			x = min(x, a[i]);
		return x;
	}

	static int max(int a[]) {
		int x = -1_000_000_00_9;
		for (int i = 0; i < a.length; i++)
			x = max(x, a[i]);
		return x;
	}

	static long min(long a[]) {
		long x = (long) 3e18;
		for (int i = 0; i < a.length; i++)
			x = min(x, a[i]);
		return x;
	}

	static long max(long a[]) {
		long x = -(long) 3e18;
		for (int i = 0; i < a.length; i++)
			x = max(x, a[i]);
		return x;
	}

	static int power(int x, int y) {
		int res = 1;
		while (y > 0) {
			if (y % 2 == 1)
				res = (res * x);
			y >>= 1;
			x = (x * x);
		}
		return res;
	}

	static long power(long x, long y) {
		long res = 1;
		while (y > 0) {
			if (y % 2 == 1)
				res = (res * x);
			y >>= 1;
			x = (x * x);
		}
		return res;
	}

	static void intsort(int[] a) {
		List<Integer> temp = new ArrayList<Integer>();
		for (int i = 0; i < a.length; i++)
			temp.add(a[i]);
		Collections.sort(temp);
		for (int i = 0; i < a.length; i++)
			a[i] = temp.get(i);
	}

	static void longsort(long[] a) {
		List<Long> temp = new ArrayList<Long>();
		for (int i = 0; i < a.length; i++)
			temp.add(a[i]);
		Collections.sort(temp);
		for (int i = 0; i < a.length; i++)
			a[i] = temp.get(i);
	}

	static void reverseintsort(int[] a) {
		List<Integer> temp = new ArrayList<Integer>();
		for (int i = 0; i < a.length; i++)
			temp.add(a[i]);
		Collections.sort(temp);
		Collections.reverseOrder();
		for (int i = 0; i < a.length; i++)
			a[i] = temp.get(i);
	}

	static void reverselongsort(long[] a) {
		List<Long> temp = new ArrayList<Long>();
		for (int i = 0; i < a.length; i++)
			temp.add(a[i]);
		Collections.sort(temp);
		Collections.reverseOrder();
		for (int i = 0; i < a.length; i++)
			a[i] = temp.get(i);
	}

	static class longpair implements Comparable<longpair> {
		long x, y;

		longpair(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(longpair p) {
			return Long.compare(this.x, p.x);
		}
	}

	public static int gcd(int a, int b) {
		BigInteger b1 = BigInteger.valueOf(a);
		BigInteger b2 = BigInteger.valueOf(b);
		BigInteger gcd = b1.gcd(b2);
		return gcd.intValue();
	}

	public static long gcd(long a, long b) {
		BigInteger b1 = BigInteger.valueOf(a);
		BigInteger b2 = BigInteger.valueOf(b);
		BigInteger gcd = b1.gcd(b2);
		return gcd.longValue();
	}
}