#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n, m, k;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> m >> k >> s;
    int skip = k - n - m;
    if (m > n) swap(n, m);
    int A[256] = {};
    for (auto& ch : s) A[ch]++;
    long long ats = LLONG_MAX / 10;
    for (int i = 'A'; i <= 'Z'; i++) {
      int left = k - A[i];
      vector<int> DP(k + 1);
      DP[0] = 1;
      for (int j = 'A'; j <= 'Z'; j++)
        if (i != j)
          for (int z = k - A[j]; z >= 0; z--)
            if (DP[z]) DP[z + A[j]] = 1;
      for (long long j = 0; j <= min(A[i], n); j++)
        if (DP[n - j]) ats = min(ats, j * max(0LL, A[i] - j - skip));
    }
    cout << ats << "\n";
  }
}
