#include <bits/stdc++.h>
using namespace std;
const long long max_n = INT_MAX - 1000000;
long long dp[30][30001];
pair<int, int> par[30][30001];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, m, k;
    cin >> n >> m >> k;
    if (n > m) swap(n, m);
    map<char, long long> mp;
    string ss = "";
    for (long long i = 0; i < k; i++) {
      char a;
      cin >> a;
      mp[a]++;
      ss += a;
    }
    vector<int> vv;
    for (auto i : mp) {
      vv.push_back(i.second);
    }
    long long ans = LONG_MAX;
    for (int i1 = 0; i1 < vv.size(); i1++) {
      vector<int> v = vv;
      v.erase(v.begin() + i1);
      v.insert(v.begin(), vv[i1]);
      for (long long i = 0; i < v.size(); i++) {
        for (long long j = 0; j <= m; j++) {
          dp[i][j] = max_n;
        }
      }
      for (int i = 0; i < v.size(); i++) {
        for (long long j = 1; j <= m; j++) {
          if (i == 0) {
            if (j <= v[i]) {
              dp[i][j] = v[i];
            }
          } else {
            if (dp[0][j] == max_n) {
              if (j <= v[i]) {
                dp[i][j] = v[i] + v[0];
                dp[i][j] = min(dp[i - 1][j], dp[i][j]);
              } else {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + v[i]);
              }
            } else {
              dp[i][j] = dp[0][j];
            }
          }
        }
      }
      if (v[0] - (dp[v.size() - 1][n] - n) >= 0)
        ans = min(ans, (v[0] - (dp[v.size() - 1][n] - n)) *
                           max((long long)0,
                               (dp[v.size() - 1][n] - n - (k - n - m))));
      if (v[0] - (dp[v.size() - 1][m] - m) >= 0)
        ans = min(ans, (v[0] - (dp[v.size() - 1][m] - m)) *
                           max((long long)0,
                               (dp[v.size() - 1][m] - m - (k - n - m))));
    }
    cout << ans << '\n';
  }
  return 0;
}
