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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int cases = in.nextInt();
            for (int x = 0; x < cases; x++) {
                int n = in.nextInt();
                int k = in.nextInt();
                String s = in.nextString();

                // reverse S;

                byte[] strAsByteArray = s.getBytes();
                byte[] result = new byte[strAsByteArray.length];

                // Store result in reverse order into the
                // result byte[]
                for (int i = 0; i < strAsByteArray.length; i++)
                    result[i] = strAsByteArray[strAsByteArray.length - i - 1];

                String reversed = new String(result);

                char[] ca = s.toCharArray();
                boolean res = place(n, k, ca);
                if (res == false) {
                    out.println("NO");
                    continue;
                }

                res = validate(n, k, ca);
                if (res == false) {
                    out.println("NO");
                } else {
                    out.println("YES");
                }

            }
        }

        private boolean place(int n, int k, char[] chars) {

            int sum = 0;
            int qs = 0;
            HashMap<Integer, Integer> qLinks = new HashMap<>();


            Queue<Integer> questionMarkIndex = new LinkedList<>();
            for (int i = 0; i < k; i++) {
                char c = chars[i];
                if (c == '1') {
                    sum += 1;
                }
                if (c == '0') {
                    sum -= 1;
                }
                if (c == '?') {
                    qs++;
                }
            }

            for (int i = k; i <= n; i++) {

                if (i == n) {
                    break;
                }

                int idxr = i;
                int idxa = i - k;
                char r = chars[idxr];
                char a = chars[idxa];

                if (a == '1') {

                    if (r == '0') {
                        return false;
                    }

                    if (r == '?') {
                        chars[idxr] = '1';

                    }
                }

                if (a == '0') {
                    if (r == '0') {
                    }

                    if (r == '1') {
                        return false;
                    }

                    if (r == '?') {
                        chars[idxr] = '0';
                    }
                }

                if (a == '?') {

                    if (r == '?') {
                        qLinks.put(idxr, idxa);
                    } else {
                        Integer f = idxa;
                        while (f != null) {
                            chars[f] = r;
                            f = qLinks.remove(f);
                        }
                    }

                }

                if (a == '1') {
                    sum -= 1;
                }
                if (a == '0') {
                    sum += 1;
                }
                if (a == '?') {
                    qs--;
                }

                if (r == '1') {
                    sum += 1;
                }
                if (r == '0') {
                    sum -= 1;
                }
                if (r == '?') {
                    qs++;
                }

            }

            // maintain running count of ?s


            return true;
        }

        private boolean validate(int n, int k, char[] chars) {

            int sum = 0;
            int qs = 0;
            HashMap<Integer, Integer> qLinks = new HashMap<>();


            Queue<Integer> questionMarkIndex = new LinkedList<>();
            for (int i = 0; i < k; i++) {
                char c = chars[i];
                if (c == '1') {
                    sum += 1;
                }
                if (c == '0') {
                    sum -= 1;
                }
                if (c == '?') {
                    qs++;
                }
            }

            for (int i = k; i <= n; i++) {
                if (Math.abs(sum) > qs) {
                    return false;
                }

                if (i == n) {
                    break;
                }

                int idxr = i;
                int idxa = i - k;
                char r = chars[idxr];
                char a = chars[idxa];

                if (a == '1') {
                    sum -= 1;
                }
                if (a == '0') {
                    sum += 1;
                }
                if (a == '?') {
                    qs--;
                }

                if (r == '1') {
                    sum += 1;
                }
                if (r == '0') {
                    sum -= 1;
                }
                if (r == '?') {
                    qs++;
                }

            }

            // maintain running count of ?s


            return true;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

