#include <bits/stdc++.h>   using namespace std;   const int64_t Nmax = 2e5 + 10;   const int64_t mod = 1000000007;   vector<int64_t> prime;   int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); }   int64_t isperfectsquare(int64_t a) {     double b = sqrt(a);     return (b - ceil(b) == 0);   }   int64_t pow(int64_t a, int64_t b, int64_t m) {     a = a % m;     int64_t res = 1;     while (b > 0) {       if (b & 1) {         res = res * a % m;       }       a = a * a % m;       b = b / 2;     }     return res;   }   int64_t mod_add(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a + b) % m) + m) % m;   }   int64_t mod_mul(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a * b) % m) + m) % m;   }   int64_t mod_sub(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   int64_t mod_div(int64_t a, int64_t b, int64_t m) {     a = a % m;     b = b % m;     return (mod_mul(a, pow(b, m - 2, m), m));   }   void sieve(int64_t n) {     bool isprime[n + 1];     memset(isprime, true, sizeof(isprime));     prime.push_back(2);     for (int64_t i = 3; i <= sqrt(n); i += 2) {       if (isprime[i]) {         for (int64_t j = i * i; j <= n; j += i) {           isprime[j] = false;         }       }     }     for (int64_t i = 3; i <= n; i += 2) {       if (isprime[i]) {         prime.push_back(i);       }     }   }   vector<pair<int64_t, int64_t>> Getprimefactors(int64_t n) {     vector<pair<int64_t, int64_t>> pr;     for (int64_t i = 2; i <= sqrt(n); i++) {       int64_t cnt = 0;       while (n % i == 0) {         cnt++;         n /= i;       }       if (cnt) pr.push_back({i, cnt});     }     if (n > 1) {       pr.push_back({n, 1});     }     return pr;   }   void solve() {     int64_t n, k, ans = INT_MAX;     cin >> n >> k;     string s;     cin >> s;     char rgb[] = { R ,  G ,  B };     for (int64_t i = 0; i <= n - k; i++) {       string tmp = s.substr(i, k);       int64_t val1 = 0, val2 = 0, val3 = 0;       for (int64_t j = 0; j <= k - 1; j++) {         if (tmp[j] != rgb[(j) % 3]) val1++;         if (tmp[j] != rgb[(j + 1) % 3]) val2++;         if (tmp[j] != rgb[(j + 2) % 3]) val3++;       }       ans = min({val1, val2, val3, ans});     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }   