#include #include #include #include #include #include #include #include #include #include #define LL long long #define pii pair #define piii pair #define xx first #define yy second #define ls rt << 1 #define rs rt << 1 | 1 #define lson ls, l, m #define rson rs, m + 1, r #define pdi pair using namespace std; const int N = 110; char s[N]; int c[N], dp[2][N][N]; int main () { // freopen ("in.txt", "r", stdin); int T; cin >> T; while (T--) { int n, k, l; cin >> n >> k >> l; memset (c, 0, sizeof c); for (int i = 1; i <= n; i++) { scanf ("%s", s); int len = strlen (s); for (int j = 0; j < len; j++) { int l = j, r = j, now = -1; // c[1]++; while (l >= 0 && r < len && s[l] == s[r]) { now += 2; c[now]++; l--, r++; } // cout << l + 1 << ' ' << r - 1 << endl; } for (int j = 0; j + 1 < len; j++) { int l = j, r = j + 1, now = 0; while (l >= 0 && r < len && s[l] == s[r]) { now += 2; c[now]++; l--, r++; } // cout << l + 1 << ' ' << r - 1 << endl; } } // for (int i = 1; i <= l; i++) cout << c[i] << ' '; cout << endl; memset (dp, 0, sizeof dp); int now = 0; dp[0][0][0] = 1; for (int i = 0; i < l; i++) { memset (dp[now ^ 1], 0, sizeof dp[now ^ 1]); for (int j = 0; j <= k; j++) { for (int K = 0; K <= l; K++) if (dp[now][j][K]) { for (int L = 0; L <= c[i + 1] && j + L <= k && K + L * (i + 1) <= l; L++) { dp[now ^ 1][j + L][K + L * (i + 1)] = 1; } } } now ^= 1; } cout << (dp[now][k][l] ? "True\n" : "False\n"); } }