#include <bits/stdc++.h>
using namespace std;
template <class T>
void aIn(T *a, int n) {
  for (int i = 0; i < n; i++) std::cin >> a[i];
}
template <class T>
void aOut(T *a, int n) {
  for (int i = 0; i < n; i++) std::cout << a[i] << " ";
  std::cout << endl;
}
template <class T>
void vOut(vector<T> &a) {
  for (T &x : a) std::cout << x << " ";
  std::cout << endl;
}
int n, k;
void solv() {
  cin >> n >> k;
  string s;
  cin >> s;
  int _1 = 0, _0 = 0, _w = 0;
  for (int i = 0; i < k; i++)
    if (s[i] == '0')
      ++_0;
    else if (s[i] == '1')
      ++_1;
    else
      ++_w;
  bool res;
  res = !(_1 > k / 2 || _0 > k / 2);
  for (int i = 1; i < n - k + 1 && res; i++) {
    if (s[i - 1] != s[i + k - 1] && (s[i - 1] != '?' && s[i + k - 1] != '?')) {
      res = 0;
      break;
    }
    s[i + k - 1] = (s[i + k - 1] == '?') ? s[i - 1] : s[i + k - 1];
    if (s[i - 1] == '0')
      --_0;
    else if (s[i - 1] == '1')
      --_1;
    else if (s[i - 1] == '?')
      --_w;
    if (s[i + k - 1] == '0')
      ++_0;
    else if (s[i + k - 1] == '1')
      ++_1;
    else if (s[i + k - 1] == '?')
      ++_w;
    res &= !(_1 > k / 2 || _0 > k / 2);
  }
  if (res)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    solv();
  }
}
