#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   const int inf = 0x3f3f3f3f;   const int mod = 1e9 + 7;   char s[maxn];   int ans[maxn];   void solve() {     int n, k;     scanf( %d%d , &n, &k);     scanf( %s , s + 1);     memset(ans, -1, sizeof(ans));     for (int i = 1; i <= n; i++) {       if (s[i] ==  ? ) continue;       if (ans[i % k + 1] == -1)         ans[i % k + 1] = s[i] -  0 ;       else {         if (s[i] -  0  != ans[i % k + 1]) {           printf( No n );           return;         }       }     }     int cnt1 = 0, cnt0 = 0;     for (int i = 1; i <= k; i++) {       if (ans[i] == 1) cnt1++;       if (ans[i] == 0) cnt0++;     }     if (cnt1 > k / 2 || cnt0 > k / 2 || k & 1) {       printf( No n );       return;     }     printf( Yes n );   }   int main() {     int T;     scanf( %d , &T);     while (T--) solve();     return 0;   }   