#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e10;
const int MAX_N = 30000;
const int MAX_K = 30;
int T, N, M, K;
string str;
int cnt[MAX_K + 1];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
bool dp[2][MAX_N * 3 + 1];
vector<int> v;
long long ans;
int main() {
  scanf("%d", &T);
  while (T--) {
    ans = INFLL;
    scanf("%d%d%d", &N, &M, &K);
    if (N > M) {
      int tmp = N;
      N = M;
      M = tmp;
    }
    cin >> str;
    for (int i = 0; i < MAX_K; i++) {
      cnt[i] = 0;
    }
    for (int i = 0; i < str.size(); i++) {
      cnt[str[i] - 'A']++;
    }
    while (!v.empty()) v.pop_back();
    for (int i = 0; i < MAX_K; i++) {
      if (cnt[i] != 0) {
        v.push_back(cnt[i]);
      }
    }
    for (int i = 0; i <= M; i++) {
      dp[0][i] = dp[1][i] = false;
    }
    dp[0][0] = true;
    int sum = 0;
    sort(v.begin(), v.end());
    while (!v.empty()) {
      int t = v.back();
      v.pop_back();
      if (0) cout << t << endl;
      for (int j = 0; j < M; j++) {
        if (dp[0][j] == false) continue;
        if (0) cout << j << " " << t << endl;
        if (j + t < M) {
          dp[1][j + t] = true;
          if (0) cout << "^" << j + t << endl;
        } else {
          int k = min(N, K - t - j);
          if (0) cout << "*" << k << endl;
          ans = min(ans, (long long)(M - j) * (long long)(N - k));
        }
        if (sum - j + t < N) {
          dp[1][j] = true;
        } else {
          int k = min(M, K - (sum - j) - t);
          ans = min(ans, (long long)(N - (sum - j)) * (long long)(M - k));
        }
      }
      for (int j = 0; j <= M; j++) {
        if (0) cout << dp[0][j];
        dp[0][j] = dp[1][j];
        dp[1][j] = false;
      }
      if (0) cout << endl;
      sum += t;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
