#include <bits/stdc++.h>
long long dp[200000];
using namespace std;
vector<long long> A;
int main() {
  int t, a, b, p, n;
  string s;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> a >> b >> p >> s;
    n = s.size();
    if (s[n - 2] == 'B')
      dp[n - 2] = b;
    else
      dp[n - 2] = a;
    for (int j = n - 3; j >= 0; --j) {
      if (s[j] == 'B') {
        if (s[j + 1] != 'B')
          dp[j] = dp[j + 1] + b;
        else
          dp[j] = dp[j + 1];
      } else if (s[j] == 'A') {
        if (s[j + 1] != 'A')
          dp[j] = dp[j + 1] + a;
        else
          dp[j] = dp[j + 1];
      }
    }
    int j = 0;
    long long marche = 1;
    while (j < n - 1 && dp[j] > p) {
      marche += 1;
      j++;
    }
    cout << marche << '\n';
  }
}
