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.lang.*;
import java.io.*;

public class Jan5 {

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

//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		int t = Integer.parseInt(br.readLine());
//		StringBuilder sb = new StringBuilder();
//		while (t-- > 0) {
//			String[] scn = (br.readLine()).trim().split(" ");
//			int n = Integer.parseInt(scn[0]);
//			long[] arr = new long[n];
//			scn = (br.readLine()).trim().split(" ");
//			for (int i = 0; i < n; i++) {
//				arr[i] = Long.parseLong(scn[i]);
//			}
//			sb.append("\n");
//		}
//		System.out.println(sb);
//		return;

//		first();
//		sec();
//		third();
//		four();
//		fif();
//		six();
//		sev();
		eig();
	}

	private static void first() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		ArrayList<Long> list = new ArrayList<>();
		long temp = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				long fact = 1;
				while (n % i == 0) {
					fact *= i;
					n /= i;
				}
				list.add(fact);
			}
		}
		list.add(n);
		long a = fun(1, 1, list, 0, list.size(), 2);
		System.out.println(temp / a + " " + a);
		return;
	}

	public static long fun(long a, long b, ArrayList<Long> list, int i, int n, int k) {
		if (i == n) {
			return Math.max(a, b);
		}
		long ra = fun(a * list.get(i), b, list, i + 1, n, k);
		long rb = fun(a, b * list.get(i), list, i + 1, n, k);
		return Math.min(ra, rb);
	}

	private static void sec() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String orig = br.readLine();
		String rec = br.readLine();
		int n = orig.length();
		int pos = 0, count = 0;
		for (int i = 0; i < n; i++) {
			char ch = orig.charAt(i);
			if (ch == '+')
				pos += 1;
			else
				pos -= 1;
			if (rec.charAt(i) == '?') {
				count += 1;
			}
		}

		double reach = fun_2(rec, "", 0, n, pos);
		double ans = reach / Math.pow(2, count);
		System.out.println(String.format("%.9f", ans));

		return;
	}

	public static int fun_2(String orig, String changed, int i, int n, int pos) {
		if (i == n) {
			int npos = 0;
			for (char ch : changed.toCharArray()) {
				if (ch == '+')
					npos += 1;
				else
					npos -= 1;
			}
			changed = "";
			if (npos == pos)
				return 1;
			else
				return 0;
		}
		if (orig.charAt(i) == '?') {
			int a = fun_2(orig, changed + "+", i + 1, n, pos);
			int b = fun_2(orig, changed + "-", i + 1, n, pos);
			return a + b;
		} else if (orig.charAt(i) == '+') {
			return fun_2(orig, changed + "+", i + 1, n, pos);
		} else if (orig.charAt(i) == '-') {
			return fun_2(orig, changed + "-", i + 1, n, pos);
		}
		return 0;
	}

	private static void third() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			HashSet<Long> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
				set.add(arr[i]);
			}
			int ans = 0;
			for (int dig = 1; dig < 1030; dig++) {
				boolean can = true;
				for (int i = 0; i < n; i++) {
					long newnum = (dig ^ arr[i]);
					if (!set.contains(newnum)) {
						can = false;
						break;
					}
				}
				if (can) {
					ans = dig;
					break;
				}
			}
			if (ans == 0)
				sb.append("-1");
			else
				sb.append(ans);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void four() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String str = br.readLine();
			int n = str.length();
			ArrayList<Pair> list = new ArrayList<>();
			int x = 0, y = 0;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == 'U') {
					y += 1;
				} else if (str.charAt(i) == 'D') {
					y -= 1;
				} else if (str.charAt(i) == 'R') {
					x += 1;
				} else if (str.charAt(i) == 'L') {
					x -= 1;
				}
				list.add(new Pair(x, y));
			}
			int idx = 0;
			for (idx = 0; idx < list.size(); idx++) {
				int obx = list.get(idx).x;
				int oby = list.get(idx).y;
				x = 0;
				y = 0;
				for (int i = 0; i < n; i++) {
					if (str.charAt(i) == 'U' && !(x == obx && y + 1 == oby)) {
						y += 1;
					} else if (str.charAt(i) == 'D' && !(x == obx && y - 1 == oby)) {
						y -= 1;
					} else if (str.charAt(i) == 'R' && !(x + 1 == obx && y == oby)) {
						x += 1;
					} else if (str.charAt(i) == 'L' && !(x - 1 == obx && y == oby)) {
						x -= 1;
					}
				}
				if (x == 0 && y == 0) {
					x = obx;
					y = oby;
					break;
				}
			}
			if (idx != n)
				sb.append(x + " " + y);
			else
				sb.append("0 0");

			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	static class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

	}

	private static void fif() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			HashMap<Double, Long> map = new HashMap<>();
			HashMap<Double, Long> opp = new HashMap<>();
			for (int i = 0; i < n; i++) {
				scn = (br.readLine()).trim().split(" ");
				int x1 = Integer.parseInt(scn[0]);
				int y1 = Integer.parseInt(scn[1]);
				int x2 = Integer.parseInt(scn[2]);
				int y2 = Integer.parseInt(scn[3]);
				double a = Math.atan((double) (y2 - y1) / (double) (x2 - x1));
				if (x2 - x1 > 0) {
					opp.put(a, opp.getOrDefault(a, 0l) + 1);
				} else {
					map.put(a, map.getOrDefault(a, 0l) + 1);
				}
			}
//			System.out.println(map);
//			System.out.println(opp);
			long count = 0;
			for (double key : map.keySet()) {
				if (map.containsKey(key + Math.PI)) {
					count += (map.get(key) * map.get(key + Math.PI));
				}
				if (opp.containsKey(key)) {
					count += (map.get(key) * opp.get(key));
				}
				if (key == -0.0 && opp.containsKey(0.0)) {
					count += (map.get(key) * opp.get(0.0));

				}
			}
			sb.append(count);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void six() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			int m = Integer.parseInt(scn[1]);
			int a = Integer.parseInt(scn[2]);
			int b = Integer.parseInt(scn[3]);

			long[] arr = new long[m];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < m; i++) {
				arr[i] = Long.parseLong(scn[i]);
			}
			sort(arr);
			int count = 0;
			if (a < b) {
				for (int i = 0; i < m; i++) {
					b -= 1;
					if (a != b && arr[i] - 1 <= b) {
						count += 1;
						b -= (arr[i] - 1);
						a -= (arr[i] - 1);
					} else {
						break;
					}
				}
			} else {
				for (int i = 0; i < m; i++) {
					b += 1;
					if (a != b && arr[i] - 1 <= n - b) {
						count += 1;
						b += arr[i] - 1;
						a += arr[i] - 1;
					} else {
						break;
					}
				}
			}
			sb.append(count);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void sev() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			int m = Integer.parseInt(scn[1]);
			char[][] arr = new char[n][m];
			long[][] dp = new long[n][m];

			for (int i = 0; i < n; i++) {
				scn = (br.readLine()).trim().split("");
				for (int j = 0; j < m; j++) {
					arr[i][j] = scn[j].charAt(0);
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (j == 0) {
						if (arr[i][j] == '*')
							dp[i][j] = 1;
						else
							dp[i][j] = 0;
					} else {
						if (arr[i][j] == '*') {
							dp[i][j] = dp[i][j - 1] + 1;
						}
					}
				}
			}

			long count = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (arr[i][j] != '*')
						continue;
					int height = 1;
					int x = i + 1;
					while (x < n) {
						long width = 2 * height + 1;
						if (j + height < m && dp[x][j + height] >= width) {
							x += 1;
							height += 1;
						} else {
							break;
						}

					}
					count += height;
				}
			}
			sb.append(count);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void eig() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());

		while (t-- > 0) {
			StringBuilder sb = new StringBuilder();
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			int m = Integer.parseInt(scn[1]);
			long[][] arr = new long[n][m];
			for (int i = 0; i < n; i++) {
				scn = (br.readLine()).trim().split("");
				for (int j = 0; j < m; j++)
					arr[i][j] = Long.parseLong(scn[j]);
			}
			int count = 0;
			for (int i = 0; i < n; i += 2) {
				for (int j = 0; j < m; j += 2) {
					if (j + 1 == m) {
						j -= 1;
					}
					if (i + 1 == n) {
						i -= 1;
					}
					ArrayList<Integer> zero = new ArrayList<>();
					ArrayList<Integer> one = new ArrayList<>();
					for(int k=i;k<=i+1;k++) {
						for(int kk=j;kk<=j+1;kk++) {
							if (arr[k][kk] == 0) {
								zero.add(k+1);
								zero.add(kk+1);
							} else {
								one.add(k+1);
								one.add(kk+1);
							}
							arr[k][kk]=0;
						}
					}

					int s0 = zero.size();
					if (s0 == 2) {
						count += 1;
						print1(one, sb);
					} else if (s0 == 4) {
						count += 2;
						print2(one, zero, sb);
					} else if (s0 == 6) {
						count += 3;
						print3(one, zero, sb);
					} else if (s0 == 0) {
						count += 4;
						ArrayList<Integer> newone = new ArrayList<>();
						int a = 0;
						for (int ele : one) {
							zero.add(ele);
							sb.append(ele+" ");
							a += 1;
							if (a == 6)
								break;
						}
						sb.append("\n");
						newone.add(one.get(a));
						newone.add(one.get(a + 1));
						print3(newone, zero, sb);
					}
				}
			}
			System.out.println(count);
			System.out.print(sb);
		}
		return;
	}

	private static void print2(ArrayList<Integer> one, ArrayList<Integer> zero, StringBuilder sb) {
		ArrayList<Integer> list = new ArrayList<>();
		for (int ele : zero) {
			sb.append(ele + " ");
			list.add(ele);
		}
		sb.append(one.get(2) + " ");
		sb.append(one.get(3) + " ");
		list.add(one.get(0));
		list.add(one.get(1));
		sb.append("\n");
		print1(list, sb);
	}

	private static void print3(ArrayList<Integer> one, ArrayList<Integer> zero, StringBuilder sb) {
		ArrayList<Integer> newone = new ArrayList<>();
		ArrayList<Integer> newzero = new ArrayList<>();
		int count = 0;
		for (int ele : zero) {
			sb.append(ele + " ");
			newone.add(ele);
			count += 1;
			if (count == 4)
				break;
		}
		sb.append(one.get(0) + " ");
		sb.append(one.get(1) + " ");
		newzero.add(zero.get(4));
		newzero.add(zero.get(5));
		newzero.add(one.get(0));
		newzero.add(one.get(1));
		sb.append("\n");

		print2(newone, newzero, sb);
	}

	public static void print1(ArrayList<Integer> one, StringBuilder sb) {
		for (int k : one) {
			sb.append(k + " ");
		}
		sb.append("\n");
	}

	public static void sort(long[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			long temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}
		Arrays.sort(arr);
	}
}