#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, p;
    long long dp[100001];
    cin >> a >> b >> p;
    string str;
    cin >> str;
    int N = str.length();
    memset(dp, 0, sizeof(dp));
    int cost = 0;
    for (int i = N - 2; i >= 0; i--) {
      if (i == N - 2) {
        dp[i] = (str[i] == 'A' ? a : b);
      } else if (str[i] != str[i + 1]) {
        dp[i] = dp[i + 1] + (str[i] == 'A' ? a : b);
      } else {
        dp[i] = dp[i + 1];
      }
    }
    int ans = N - 1;
    for (int i = 0; i < N; i++)
      if (dp[i] <= p) {
        ans = i;
        break;
      }
    printf("%d\n", ans + 1);
  }
  return 0;
}
