#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const long long N = 1e6 + 2;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    long long n = s.length();
    long long dis[n];
    dis[n - 1] = 0;
    dis[n - 2] = (s[n - 2] == 'A' ? a : b);
    for (long long i = n - 3; i >= 0; i--) {
      if (s[i] == s[i + 1])
        dis[i] = dis[i + 1];
      else {
        if (s[i] == 'A') {
          dis[i] = dis[i + 1] + a;
        } else
          dis[i] = dis[i + 1] + b;
      }
    }
    long long ans = 1e12;
    for (long long i = 0; i < n; i++) {
      long long cost = dis[i];
      if (cost <= p) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << "\n";
  }
}
