#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b, p;
    cin >> a >> b >> p;
    cin.ignore();
    string s;
    cin >> s;
    int n = s.length();
    vector<long long int> v(n);
    v[n - 1] = 0;
    if (s[n - 2] == 'A')
      v[n - 2] = a;
    else
      v[n - 2] = b;
    char c = s[n - 2];
    for (int i = n - 3; i >= 0; i--) {
      if (s[i] == c) {
        v[i] = v[i + 1];
      } else {
        v[i] = v[i + 1] + (s[i] == 'A') * a + (s[i] == 'B') * b;
        c = s[i];
      }
    }
    int i;
    for (i = 0; i < s.length(); i++) {
      if (v[i] <= p) break;
    }
    cout << i + 1 << '\n';
  }
}
