#include <bits/stdc++.h>
using namespace std;
long long _, a, b, c, ans, i;
string s;
bool check(long long x) {
  long long sum = 0;
  if (s[x - 1] == 'A')
    sum += a;
  else
    sum += b;
  for (long long i = x; i < s.length() - 1; i++)
    if (s[i] == s[i - 1])
      continue;
    else {
      if (s[i] == 'A')
        sum += a;
      else
        sum += b;
    }
  return sum <= c;
}
int main() {
  cin >> _;
  while (_--) {
    cin >> a >> b >> c;
    cin >> s;
    ans = 0;
    long long l = 1, r = s.length();
    while (l <= r) {
      long long mid = (l + r) / 2;
      if (check(mid)) {
        ans = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    if (ans == 0) ans = s.length();
    cout << ans << endl;
  }
}
