#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const long long maxn = 100000 + 9;
const long long maxm = 100000 + 9;
const long long mod = 1000000007;
inline long long _() {
  long long f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
char s[maxn];
long long idx[maxn], hf[maxn], cnt;
void solve() {
  cnt = 0;
  long long a, b, p;
  cin >> a >> b >> p;
  scanf("%s", s);
  char pre = s[0];
  for (long long i = 1, res = 0; s[i]; i++) {
    if (s[i] != pre || !s[i + 1]) {
      cnt++;
      idx[cnt] = i + 1;
      hf[cnt] = (res += (pre == 'A') ? a : b);
    }
    pre = s[i];
  }
  if (hf[cnt] <= p)
    cout << 1 << endl;
  else {
    long long pos = lower_bound(hf + 1, hf + 1 + cnt, hf[cnt] - p) - hf;
    cout << idx[pos] << endl;
  }
  return;
}
signed main() {
  long long T;
  cin >> T;
  while (T--) solve();
  return 0;
}
