#include <bits/stdc++.h>
using namespace std;
template <typename num_t>
inline void addmod(num_t& a, const long long& b, const int& m) {
  a = (a + b) % m;
  if (a < 0) a += m;
}
template <typename num_t>
inline void update_max(num_t& a, const num_t& b) {
  a = max(a, b);
}
template <typename num_t>
inline void update_min(num_t& a, const num_t& b) {
  a = min(a, b);
}
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) {
  return !lhs ? rhs : gcd(rhs % lhs, lhs);
}
template <typename num_t>
num_t pw(num_t n, num_t k, num_t mod) {
  long long res = 1;
  for (; k; k >>= 1) {
    if (k & 1) res = res * n % mod;
    n = 1ll * n * n % mod;
  }
  return (num_t)res;
}
const int inf = 1e9 + 7;
const long long ll_inf = 1ll * inf * inf;
const int MAX_N = 30000 + 7;
const int mod = 998244353;
int dp[MAX_N];
const int M = 26;
int cnt[M];
int n, m, k;
bool removed[M];
int calc(int rr) {
  fill_n(dp, n + 1, -inf);
  dp[0] = 0;
  for (int j = 0; j < M; ++j)
    if (cnt[j] && !removed[j]) {
      int len = cnt[j];
      static int queue_[MAX_N];
      int top = 0, bot = 0;
      int ptr = n;
      for (int i = n; i >= 0; --i) {
        while (top > bot && queue_[bot] > i) ++bot;
        while (ptr >= 0 && ptr >= i - len) {
          while (top > bot && dp[queue_[top - 1]] <= dp[ptr]) --top;
          queue_[top++] = ptr--;
        }
        int temp = dp[i] + len;
        if (top > bot) {
          update_max(dp[i], dp[queue_[bot]]);
        }
        update_max(dp[i], temp);
      }
    }
  int best = inf;
  for (int i = 0; i <= n; ++i)
    if (i + rr >= n) {
      if (dp[i] >= m) return 0;
      int extra = i + rr - n;
      if (m - dp[i] <= extra) {
        update_min(best, (n - i) * (m - dp[i]));
      }
    }
  return best;
}
void solve() {
  int test;
  cin >> test;
  while (test-- > 0) {
    cin >> n >> m >> k;
    fill_n(cnt, M, 0);
    string s;
    cin >> s;
    for (const char& c : s) cnt[c - 'A']++;
    int best = inf;
    for (int i = 0; i < M; ++i)
      if (cnt[i]) {
        removed[i] = true;
        best = min(best, calc(cnt[i]));
        removed[i] = false;
      }
    cout << best << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}
