#include <bits/stdc++.h>
using namespace std;
int memo[27][27][30005];
int vis[27][27][30005], vid = 0;
int all;
int n, m;
int cnt[27];
int solve(int idx, int in, int s) {
  if (s > n) return 1e9;
  if (idx == 26) {
    if (cnt[in] + s < n) return 1e9;
    int ms = all - s - cnt[in];
    if (ms >= m) return 0;
    int nt = n - s, mt = cnt[in] - nt;
    mt = min(mt, m - ms);
    return mt * nt;
  }
  int &res = memo[idx][in][s];
  if (vis[idx][in][s] == vid) return res;
  vis[idx][in][s] = vid;
  if (idx == in) return res = solve(idx + 1, in, s);
  res = min(solve(idx + 1, in, s), solve(idx + 1, in, s + cnt[idx]));
  return res;
}
char str[200005];
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    ++vid;
    memset(cnt, 0, sizeof cnt);
    all = 0;
    int l;
    scanf("%d %d %d", &n, &m, &l);
    scanf(" %s", str);
    all = l;
    for (int i = 0; i < l; ++i) {
      cnt[str[i] - 'A']++;
    }
    int ans = 1e9;
    for (int i = 0; i < 26; ++i) {
      ans = min(ans, solve(0, i, 0));
    }
    printf("%d\n", ans);
  }
  return 0;
}
