#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PB push_back #define SIZE(x) (int)x.size() #define clr(x,y) memset(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ALL(t) (t).begin(),(t).end() #define FOR(i,n,m) for (int i = n; i <= m; i ++) #define ROF(i,n,m) for (int i = n; i >= m; i --) #define RI(x) scanf ("%d", &(x)) #define RII(x,y) RI(x),RI(y) #define RIII(x,y,z) RI(x),RI(y),RI(z) typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; const ll mod = 1e9+7; const ll LINF = 1e18; const int INF = 1e9; const double EPS = 1e-8; /**************************************END************************************/ int cnt[105]; int dp[2][105][105]; int dd[105][105]; int main (){ int T; cin >> T; while (T --){ clr (cnt, 0); clr (dp, 0); int n, K, L; cin >> n >> K >> L; FOR (i, 0, n-1){ string t; cin >> t; string s; FOR (j, 0, SIZE (t)-1){ s += t[j]; s += t[j]; } for (int j = 0; j < SIZE(s)-1; j ++){ if (s[j] != s[j+1])continue; int num = 2; int l = j-1, r = j+2; while (l >= 0 && r < SIZE(s) && s[l] == s[r]){ num += 2; l --; r ++; } for (int k = num/2; k > 0; k -= 2){ cnt[k] ++; } } } // FOR (i, 0, L){ // cout << cnt[i] << " "; // } clr (dp, 0); int now = 0, pre = 1; dp[pre][0][0] = 1; FOR(i, 1, L){ clr (dd, 0); FOR (j, 0, K){ FOR (k, 0, L){ dp[now][j][k] = dp[pre][j][k]; // cout << dp[now][j][k] << " "; } // cout << endl; } // cout << "---------" << endl; FOR (j, 0, K-1){ for (int k = 0; k <= L-i; k ++){ if (dp[now][j][k] > 0 && dd[j][k] < cnt[i]){ if (dp[now][j+1][k+i] == 0){ dd[j+1][k+i] = dd[j][k] + 1; dp[now][j+1][k+i] = true; }else{ dd[j+1][k+i] = min(dd[j+1][k+i], dd[j][k]+1); } } } } swap (now, pre); } if (L <= 0){ puts ("False"); }else{ puts (dp[pre][K][L] ? "True" : "False"); } } }