#include <bits/stdc++.h>
using namespace std;
int a[300005];
int main(void) {
  int t;
  scanf("%d", &t);
  for (int(test) = 0; (test) < (t); (test)++) {
    int n, k;
    scanf("%d%d", &n, &k);
    char c;
    scanf("%c", &c);
    for (int(i) = 0; (i) < (n); (i)++) {
      scanf("%c", &c);
      if (c == '?') {
        a[i] = -1;
      } else {
        a[i] = c - '0';
      }
    }
    int s[2] = {0};
    for (int(i) = 0; (i) < (k); (i)++) {
      if (a[i] != -1) {
        s[a[i]]++;
      }
    }
    int needed[2] = {k / 2 - s[0], k / 2 - s[1]};
    if (needed[0] < 0 || needed[1] < 0) {
      printf("NO\n");
      continue;
    }
    int p2 = k;
    int p1 = 0;
    bool ok = 1;
    while (p2 < n) {
      int n2[2] = {needed[0], needed[1]};
      int diff = 0;
      if (a[p1] == -1) {
        if (a[p2] == -1) {
        } else {
          s[a[p2]]++;
          needed[a[p2]]--;
        }
      } else {
        if (a[p2] == -1) {
          a[p2] = a[p1];
        } else {
          if (a[p1] != a[p2]) {
            ok = 0;
          }
          s[a[p1]]--;
          needed[a[p1]]++;
          s[a[p2]]++;
          needed[a[p2]]--;
        }
      }
      for (int(i) = 0; (i) < (2); (i)++) {
        if (needed[i] < 0 || needed[i] > k / 2) {
          ok = 0;
          break;
        }
      }
      if (!ok) {
        break;
      }
      p2++;
      p1++;
    }
    if (!ok) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
}
