#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int a, b, p;
    string s;
    cin >> a >> b >> p;
    cin >> s;
    int len = s.length();
    int ans = 0;
    int cur = 'Z';
    int cur_val = 0;
    for (int i = len - 2; i >= 0; i--) {
      if (cur != s[i]) {
        cur = s[i];
        if (cur == 'A') {
          cur_val += a;
        } else {
          cur_val += b;
        }
        if (cur_val > p) {
          ans = i + 1;
          break;
        }
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
