#include <bits/stdc++.h>
using namespace std;
long long T, a, b, n, k;
string s;
void solve() {
  cin >> n >> k;
  cin >> s;
  int i1 = 0, i2 = k;
  for (; i2 < n; i2++, i1++) {
    if (s[i1] == '?' && s[i2] != '?')
      s[i1] = s[i2];
    else if (s[i1] != '?' && s[i2] == '?')
      s[i2] = s[i1];
    else if (s[i1] != '?' && s[i2] != '?' && s[i1] != s[i2]) {
      cout << "NO" << endl;
      return;
    }
  }
  i1 = n - 1 - k, i2 = n - 1;
  for (; i1 >= 0; i1--, i2--) {
    if (s[i1] == '?' && s[i2] != '?')
      s[i1] = s[i2];
    else if (s[i1] != '?' && s[i2] == '?')
      s[i2] = s[i1];
    else if (s[i1] != '?' && s[i2] != '?' && s[i1] != s[i2]) {
      cout << "NO" << endl;
      return;
    }
  }
  int qs = 0;
  int ones = 0;
  int zeros = 0;
  for (int i = 0; i < k; i++) {
    if (s[i] == '1')
      ones++;
    else if (s[i] == '0')
      zeros++;
    else
      qs++;
  }
  int delta = max(ones, zeros) - min(ones, zeros);
  if (qs >= delta)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  cin >> T;
  int i = 1;
  while (T--) {
    solve();
  }
  return 0;
}
