#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long MAXN = 1e6 + 5;
long long n, a, b, p;
char s[MAXN];
long long f[MAXN];
void solve() {
  cin >> a >> b >> p;
  cin >> s + 1;
  long long n = strlen(s + 1);
  if (s[n] == 'A')
    f[n] = a;
  else
    f[n] = b;
  f[n + 1] = 0;
  long long pos = n;
  for (int i = n - 1; i >= 1; --i) {
    if (i == n - 1) {
      f[i] = (s[i] == 'A' ? a : b);
    } else if (s[i] == s[i + 1]) {
      f[i] = f[i + 1];
    } else {
      f[i] = f[i + 1] + (s[i] == 'A' ? a : b);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (f[i] <= p) {
      pos = i;
      break;
    }
  }
  cout << pos << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
