#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
char s[N];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d%d", &n, &k);
    scanf("%s", s + 1);
    int sum2 = 0, sum1 = 0, sum0 = 0;
    for (int i = 1; i <= k; i++) {
      if (s[i] == '1')
        sum1++;
      else if (s[i] == '0')
        sum0++;
      else
        sum2++;
    }
    int f = 1;
    int vis1, vis0;
    vis1 = k / 2 - sum1;
    vis0 = k / 2 - sum0;
    if (sum1 > k / 2 || sum0 > k / 2) f = 0;
    for (int i = k + 1; i <= n; i++) {
      if (s[i] == '1') {
        if (s[i - k] == '0') {
          vis0++;
        } else if (s[i - k] == '?') {
          vis1--;
          sum2--;
          sum1++;
        }
      } else if (s[i] == '0') {
        if (s[i - k] == '1') {
          vis1++;
        } else if (s[i - k] == '?') {
          vis0--;
          sum2--;
          sum0++;
        }
      } else {
        if (s[i - k] == '1')
          s[i] = '1';
        else if (s[i - k] == '0')
          s[i] = '0';
      }
      if (vis0 + vis1 > sum2) {
        f = 0;
        break;
      }
      if ((sum1 + vis1) != (sum0 + vis0)) {
        f = 0;
        break;
      }
      if (vis1 < 0 || vis0 < 0) {
        f = 0;
        break;
      }
    }
    if (!f)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}
