#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    long long a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    long long n = s.size();
    long long dp[n];
    dp[n - 1] = 0;
    if (s[n - 2] == 'A')
      dp[n - 2] = a;
    else
      dp[n - 2] = b;
    for (long long i = n - 3; i >= 0; i--) {
      if (s[i] == s[i + 1])
        dp[i] = dp[i + 1];
      else if (s[i] == 'A')
        dp[i] = dp[i + 1] + a;
      else
        dp[i] = dp[i + 1] + b;
    }
    long long ans = n;
    for (long long i = 0; i < n; i++) {
      if (dp[i] <= p) {
        cout << i + 1 << '\n';
        break;
      }
    }
  }
  return 0;
}
