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