#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using pcc = pair<char, char>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vc = vector<char>;
using vd = vector<double>;
bool cmp(pii a, pii b) {
  if (a.second * b.first < b.second * a.first) return true;
  return false;
}
int main(int argc, char* argv[]) {
  ll t, a, b, p, i, j, l;
  char str[200100];
  scanf("%d%*c", &(t));
  while (t--) {
    scanf("%lld %lld %lld", &a, &b, &p);
    scanf("%s", str);
    l = strlen(str);
    ll pre = 0, tot = 0;
    for (i = 1; i < l; i++) {
      if (str[i] != str[pre]) {
        if (str[pre] == 'A') {
          tot += a;
        } else
          tot += b;
        pre = i;
      }
    }
    if (pre < l - 1) {
      if (str[pre] == 'A') {
        tot += a;
      } else
        tot += b;
    }
    pre = 0;
    for (i = 0; i < l; i++) {
      if (tot <= p) break;
      if (str[i] != str[pre]) {
        if (str[pre] == 'A') {
          tot -= a;
        } else
          tot -= b;
        pre = i;
      }
    }
    if (tot > p)
      pre = l;
    else
      pre++;
    printf("%lld", (pre)), printf("\n");
  }
  return 0;
}
