#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int i, a, b, p;
    string s;
    cin >> a >> b >> p >> s;
    s[s.size() - 1] = 'z';
    for (i = s.size() - 1; p >= 0 && i > 0; i--) {
      if (s[i] != s[i - 1]) {
        if (s[i - 1] == 'A')
          p -= a;
        else
          p -= b;
      }
    }
    if (p >= 0)
      cout << 1 << endl;
    else if (p < 0)
      cout << i + 2 << endl;
  }
  return 0;
}
