#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const int maxc = 26;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return f * x;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long poww(long long x, long long y, long long p) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % p;
    x = x * x % p;
    y >>= 1;
  }
  return ans;
}
bool is_prime(long long x) {
  if (x == 1) return 0;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int t;
long long a, b, p;
string s;
vector<pair<int, int> > pos;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    pos.clear();
    cin >> a >> b >> p >> s;
    int ans = 1;
    int bus = 0, tram = 0;
    int now = s[0] - 'A';
    if (!now)
      bus++;
    else
      tram++;
    pos.push_back(make_pair(0, now));
    for (int i = 1; i < s.size(); i++) {
      int cur = s[i] - 'A';
      if (i == s.size() - 1) {
        pos.push_back(make_pair(i, -1));
        continue;
      }
      if (cur != now) {
        if (!cur)
          bus++;
        else
          tram++;
        now = cur;
        pos.push_back(make_pair(i, now));
      }
    }
    for (int i = 0; i < pos.size(); i++) {
      int id = pos[i].first, k = pos[i].second;
      if (a * bus + b * tram <= p) {
        cout << pos[i].first + 1 << endl;
        break;
      } else {
        if (!k)
          bus--;
        else
          tram--;
      }
    }
  }
}
