func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll mod = 1e18 + 7;   void solve() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     for (int i = 0; i < k; i++) {       int z = 0, one = 0, j = i + k;       for (j; j < n; j += k) {         if (s[j] ==  1 )           one++;         else if (s[j] ==  0 )           z++;       }       if (one > 0 && z > 0) {         cout <<  NO n ;         return;       }       if ((one > 0 && s[i] ==  0 ) || (z > 0 && s[i] ==  1 )) {         cout <<  NO n ;         return;       }       if (one > 0) {         j = i;         for (j; j < n; j += k) {           s[j] =  1 ;         }       } else if (z > 0) {         j = i;         for (j; j < n; j += k) {           s[j] =  0 ;         }       }     }     int z = 0, one = 0;     for (int i = 0; i < k; i++) {       if (s[i] ==  0 )         z++;       else if (s[i] ==  1 )         one++;     }     if (one > k / 2 || z > k / 2) {       cout <<  NO n ;     } else       cout <<  YES n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }   