#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  long long c;
  cin >> c;
  while (c--) {
    long long b, t, r;
    cin >> b >> t >> r;
    long long i;
    char c = 'X';
    string s;
    cin >> s;
    long long cost = 0, index = s.size();
    for (i = s.size() - 2; i >= 0; i--) {
      if (s[i] != c) {
        c = s[i];
        if (c == 'A') {
          cost += b;
        } else {
          cost += t;
        }
      }
      if (cost <= r) {
        index = i + 1;
      }
    }
    cout << index << "\n";
  }
}
