#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  ll a, b, p;
  string s;
  cin >> a >> b >> p >> s;
  ll n = s.length();
  s[n - 1] = s[n - 2];
  vector<ll> cost(n, 0);
  if (s[n - 1] == 'A')
    cost[n - 1] = a;
  else
    cost[n - 1] = b;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] != s[i + 1]) {
      if (s[i] == 'A')
        cost[i] = cost[i + 1] + a;
      else
        cost[i] = cost[i + 1] + b;
    } else
      cost[i] = cost[i + 1];
  }
  for (int i = 0; i < n; i++)
    if (cost[i] <= p) {
      cout << i + 1 << endl;
      return;
    }
  cout << n << endl;
}
int main() {
  int ___T;
  scanf("%d", &___T);
  for (int cs = 1; cs <= ___T; cs++) {
    solve();
  }
  return 0;
}
