#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   void solve(int tc) {     int n, k;     cin >> n >> k;     string s;     cin >> s;     for (int i = k; i < s.size(); i++) {       if (s[i] ==  ? ) {         if (s[i - k] !=  ? ) {           s[i] = s[i - k];         }       } else {         if (s[i - k] ==  ? ) {           s[i - k] = s[i];         } else {           if (s[i] != s[i - k]) {             cout <<  NO  << endl;             return;           }         }       }     }     int count = 0;     int free = 0;     for (int i = 0; i < s.size(); i++) {       if (i >= k) {         if (s[i - k] ==  ? ) {           free--;         } else {           count -= ((s[i - k] ==  1 ) ? 1 : 0);         }       }       if (s[i] ==  ? ) {         free++;       } else {         count += ((s[i] ==  1 ) ? 1 : 0);       }       if (i >= k - 1) {         if (count > k / 2 || count + free < k / 2) {           cout <<  NO  << endl;           return;         }       }     }     cout <<  YES  << endl;   }   int main() {     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       solve(i);     }     return 0;   }   