#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0LL) return b;
  if (b == 0LL) return a;
  return gcd(b, a % b);
}
const int N = 27;
const int M = 30004;
bool dp[N][M];
int first[N];
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < N; i++) first[i] = 0;
  char c;
  for (int i = 0; i < k; i++) {
    cin >> c;
    first[c - 'A' + 1]++;
  }
  long long ans = 1000000000000000018LL;
  for (int c = 1; c < N; c++) {
    if (first[c] == 0) continue;
    for (int i = 0; i < N; i++)
      for (int j = 0; j <= n; j++) dp[i][j] = false;
    dp[0][0] = true;
    for (int i = 0; i < N - 1; i++)
      for (int j = 0; j <= n; j++) {
        if (dp[i][j]) {
          dp[i + 1][j] = true;
          if (i + 1 == c) continue;
          if (j + first[i + 1] >= n && k - j - first[i + 1] >= m) ans = 0;
          if (j + first[i + 1] <= n) dp[i + 1][j + first[i + 1]] = true;
        }
      }
    long long rw, col;
    for (int j = 0; j <= n; j++)
      if (dp[N - 1][j]) {
        rw = n - j;
        col = max(0, m - (k - j - first[c]));
        if (rw + col <= first[c]) ans = min(ans, rw * col);
      }
  }
  cout << ans << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  clock_t clk = clock();
  int t = 1;
  cin >> t;
  for (int tests = 1; tests <= t; tests++) {
    solve();
  }
  clk = clock() - clk;
  cerr << "Time Elapsed: " << fixed << setprecision(10)
       << ((long double)clk) / CLOCKS_PER_SEC << "\n";
  return 0;
}
