#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    int n = s.size();
    long long int ar[n];
    char ch = s[0];
    ar[0] = 0;
    for (int i = 1; i < n - 1; i++) {
      if (s[i] != ch) {
        int sum = ch == 'A' ? a : b;
        ar[i] = ar[i - 1] + sum;
        ch = s[i];
      } else {
        ar[i] = ar[i - 1];
      }
    }
    ar[n - 1] = ar[n - 2] + (ch == 'A' ? a : b);
    int i;
    for (i = 0; i < n - 1; i++) {
      if (ar[n - 1] - ar[i] <= p) {
        cout << i + 1;
        break;
      }
    }
    if (i == n - 1) cout << n;
    cout << endl;
  }
}
