#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
void solve() {
  long long a, b, p;
  cin >> a >> b >> p;
  string second;
  cin >> second;
  long long n = second.size();
  long long l = -1, r = n - 1;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long ans = 0;
    long long last = mid;
    for (long long i = mid + 1; i < n; ++i) {
      if (second[i] != second[i - 1]) {
        if (second[i - 1] == 'A')
          ans += a;
        else
          ans += b;
        last = i;
      }
    }
    if (last != n - 1)
      if (second[n - 1] == 'A')
        ans += a;
      else
        ans += b;
    if (ans <= p) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r + 1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
