#include <bits/stdc++.h>
using namespace std;
const int inf = numeric_limits<int>::max();
void print() { cerr << endl; }
template <typename T, typename... Ts>
void print(T&& a, Ts&&... etc) {
  cerr << a << ' ';
  print(etc...);
}
template <typename T, typename U>
ostream& operator<<(ostream& s, const pair<T, U>& p) {
  s << "<" << p.first << ", " << p.second << ">";
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  s << "[";
  for (auto& first : v) s << first << ", ";
  if (!v.empty()) s << "\b\b";
  s << "]";
  return s;
}
struct io {
  io() {
    ios_base::Init i;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
} io;
int solve(string& s, long long a, long long b, long long p) {
  int n = s.length();
  char c = 'C';
  long long cost = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (c != s[i]) {
      if (s[i] == 'A') {
        if (cost + a > p) {
          return i + 2;
        }
        cost += a;
      } else {
        if (cost + b > p) {
          return i + 2;
        }
        cost += b;
      }
      c = s[i];
    }
  }
  return 1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    cout << solve(s, a, b, p) << '\n';
  }
  return 0;
}
