#include <iostream> using namespace std; int main() { int q; cin >> q; while (q--) { int n, k; cin >> n >> k; string s; cin >> s; // 统计差异数目 int i = 0, j = n - 1, cnt = 0; while (i < j) { if (s[i] != s[j]) { ++ cnt; } ++i, --j; } // 无法通过反转构成回文串 if (cnt > k) { cout << "NO" << endl; } else { // 先通过 cnt 次操作使得 s 成为回文串 k -= cnt; // if (n & 1) { // cout << "YES" << endl; // } else { // if (k & 1) { // cout << "NO" << endl; // } else { // cout << "YES" << endl; // } // } // 当 s 长度为奇数时,剩余次数只需要反转其中间位置 // 当 s 长度为偶数时,需要成对反转 if (n & 1 || !(k & 1)) { cout << "YES" << endl; } else { cout << "NO" << endl; } } } } // 64 位输出请用 printf("%lld")