#include <bits/stdc++.h>
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
using namespace std;
unordered_map<int, bool> here;
const int nax = 2e5;
using ll = long long;
const ll mod = 998244353;
void sol() {
  ll a, b, p;
  scanf("%lld%lld%lld", &a, &b, &p);
  string s;
  cin >> s;
  const ll n = s.length();
  vector<ll> pre(n);
  pre[n - 1] = 0;
  pre[n - 2] = (s[n - 2] == 'A' ? a : b);
  for (int i = n - 3; i >= 0; --i) {
    if (s[i] == s[i + 1]) {
      pre[i] = pre[i + 1];
    } else {
      pre[i] = pre[i + 1] + (s[i] == 'A' ? a : b);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (pre[i] <= p) {
      printf("%d\n", i + 1);
      return;
    }
  }
  printf("%d\n", n);
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    sol();
  }
}
