A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each).

You are given an integer k and a string s which is composed only of characters 0, 1, and ?. You need to determine whether you can make a k-balanced bitstring by replacing every ? characters in s with either 0 or 1.

A string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

The first line of each test case contains two integers n and k (2 ≤ k ≤ n ≤ 3 ⋅ 10^5, k is even) — the length of the string and the parameter for a balanced bitstring.

The next line contains the string s (|s| = n). It is given that s consists of only 0, 1, and ?.

It is guaranteed that the sum of n over all test cases does not exceed 3 ⋅ 10^5.

Output

For each test case, print YES if we can replace every ? in s with 0 or 1 such that the resulting bitstring is k-balanced, or NO if it is not possible.

Example

Input


9
6 4
100110
3 2
1?1
3 2
1?0
4 4
????
7 4
1?0??1?
10 10
11??11??11
4 2
1??1
4 4
?0?0
6 2
????00


Output


YES
YES
NO
YES
YES
NO
NO
YES
NO

Note

For the first test case, the string is already a 4-balanced bitstring.

For the second test case, the string can be transformed into 101.

For the fourth test case, the string can be transformed into 0110.

For the fifth test case, the string can be transformed into 1100110.
// package round_000668;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C {
	public static void solve() {
		In in = new In();
		int tests = in.ni();
		outer: while (tests-- > 0) {
			int n = in.ni();
			int k = in.ni();
			char[] chars = in.ns().toCharArray();
			int half = k >> 1;

//			int[] zo = new int[2];
//			for (int i = 0; i < n; i++) {
//				if (chars[i] == '0')
//					zo[0]++;
//				if (chars[i] == '1')
//					zo[1]++;
//				if (i < k - 1)
//					continue;
//				if (i >= k) {
//					if (chars[i - k] == '0') zo[0]--;
//					else if (chars[i - k] == '1') zo[1]--;
//				}
//				if (zo[0] == half || zo[1] == half) {
//					char fill = zo[1] == half ? '0' : '1';
//					for (int j = i - k + 1; j <= i; j++) {
//						if (chars[j] == '?') {
//							chars[j] = fill;
//							zo[chars[j] - '0']++;
//						}
//					}
//				}
//			}
			char[] missing = new char[k];
			Arrays.fill(missing, '?');
			for (int i = 0; i < n; i++) {
				if (chars[i] == '?')
					continue;
				int pos = i % k;
				if (missing[pos] == '?')
					missing[pos] = chars[i];
				else if (missing[pos] != chars[i]) {
					System.out.println("NO");
					continue outer;
				}
			}
			for (int i = 0; i < n; i++) {
				if (chars[i] != '?')
					continue;
				int pos = i % k;
				chars[i] = missing[pos];
			}

			int[] ones = new int[n];
			ones[0] = chars[0] == '1' ? 1 : 0;
			for (int i = 1; i < n; i++)
				ones[i] = ones[i - 1] + (chars[i] == '1' ? 1 : 0);

			int[] zeros = new int[n];
			zeros[0] = chars[0] == '0' ? 1 : 0;
			for (int i = 1; i < n; i++)
				zeros[i] = zeros[i - 1] + (chars[i] == '0' ? 1 : 0);

			for (int i = k - 1; i < n; i += k) {
				int o = sum(i - k + 1, i, ones);
				int z = sum(i - k + 1, i, zeros);
				if (o > half || z > half) {
					System.out.println("NO");
					continue outer;
				}
			}

//			for (int i = k; i < n; i++) {
//				int o1 = sum(i - k, i - 1, ones);
//				int z1 = sum(i - k, i - 1, zeros);
//				int o2 = sum(i - k + 1, i, ones);
//				int z2 = sum(i - k + 1, i, zeros);
//
//				if (chars[i - k] != chars[i]) {
//					if (chars[i - k] != '?' && chars[i] != '?') {
//						System.out.println("NO");
//						continue outer;
//					} else {
//						if (chars[i - k] == '?') {
//							o1 += chars[i] == '1' ? 1 : 0;
//							z1 += chars[i] == '0' ? 1 : 0;
//							if (o1 > half || z1 > half) {
//								System.out.println("NO");
//								continue outer;
//							}
//						} else {
//							o2 += chars[i - k] == '1' ? 1 : 0;
//							z2 += chars[i - k] == '0' ? 1 : 0;
//							if (o2 > half || z2 > half) {
//								System.out.println("NO");
//								continue outer;
//							}
//						}
//					}
//				}
//
//			}

			System.out.println("YES");
		}
	}

	static int sum(int from, int to, int[] cum) {
		return cum[to] - (from == 0 ? 0 : cum[from - 1]);
	}

	static long sum(int from, int to, long[] cum) {
		return cum[to] - (from == 0 ? 0 : cum[from - 1]);
	}

	public static void main(String[] args) throws IOException {
		// long start = System.nanoTime();
		solve();
		// System.out.println("Elapsed: " + (System.nanoTime() - start) / 1000000 +
		// "ns");
	}

	@SuppressWarnings("unused")
	private static class In {
		final private static int BUFFER_SIZE = 1024;
		private byte[] buf;
		private InputStream is;
		private int buflen;
		private int bufptr;

		public In() {
			is = System.in;
			buf = new byte[BUFFER_SIZE];
			buflen = bufptr = 0;
		}

		public In(String input) {
			is = new ByteArrayInputStream(input.getBytes());
			buf = new byte[BUFFER_SIZE];
			buflen = bufptr = 0;
		}

		public int readByte() {
			if (bufptr >= buflen) {
				try {
					buflen = is.read(buf);
				} catch (IOException ioe) {
					throw new InputMismatchException();
				}
				bufptr = 0;
			}
			if (buflen <= 0)
				return -1;
			return buf[bufptr++];
		}

		public boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		public int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		/* Next character */
		public char nc() {
			return (char) skip();
		}

		/* Next double */
		public double nd() {
			return Double.parseDouble(ns());
		}

		/* Next string */
		public String ns() {
			final StringBuilder sb = new StringBuilder();
			int b = skip();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		/* Next integer */
		public int ni() {
			boolean minus = false;
			int num = 0;
			int b;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			while (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
				b = readByte();
			}
			return minus ? -num : num;
		}

		/* Next long */
		public long nl() {
			boolean minus = false;
			long num = 0;
			int b;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			while (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
				b = readByte();
			}
			return minus ? -num : num;
		}

		/* Next integer 1D array */
		public int[] nia(int n) {
			final int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = ni();
			return arr;
		}

		/* Next long 1D array */
		public long[] nla(int n) {
			final long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nl();
			return arr;
		}

		/* Next string 1D array */
		public String[] nsa(int n) {
			final String[] arr = new String[n];
			for (int i = 0; i < n; i++)
				arr[i] = ns();
			return arr;
		}

		/* Next char 1D array */
		public char[] nca(int n) {
			final char[] arr = new char[n];
			for (int i = 0; i < n; i++)
				arr[i] = nc();
			return arr;
		}

		/* Next double 1D array */
		public double[] nda(int n) {
			final double[] arr = new double[n];
			for (int i = 0; i < n; i++)
				arr[i] = nc();
			return arr;
		}

		/* Next integer matrix */
		public int[][] nim(int n, int m) {
			final int[][] arr = new int[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = ni();
			return arr;
		}

		/* Next long matrix */
		public long[][] nlm(int n, int m) {
			final long[][] arr = new long[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nl();
			return arr;
		}

		/* Next string matrix */
		public String[][] nsm(int n, int m) {
			final String[][] arr = new String[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = ns();
			return arr;
		}

		/* Next char matrix */
		public char[][] ncm(int n, int m) {
			final char[][] arr = new char[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nc();
			return arr;
		}

		/* Next double matrix */
		public double[][] ndm(int n, int m) {
			final double[][] arr = new double[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nd();
			return arr;
		}

		public static void log(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	}

}
