#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return (a);
  a %= b;
  return (gcd(b, a));
}
bool cmp(int a, int b) {
  if (a > b) {
    return (true);
  } else {
    return (false);
  }
}
int main() {
  int t;
  cin >> t;
  for (long long int i = 0; i < t; i++) {
    int a, b, p;
    cin >> a >> b >> p;
    string str;
    cin >> str;
    vector<pair<int, int>> vec;
    for (int i = 0; i < str.size(); i++) {
      if (i == 0) {
        if (str[i] == 'A') {
          vec.push_back(make_pair(a, 1));
        } else {
          vec.push_back(make_pair(b, 1));
        }
      } else {
        if (str[i] == str[i - 1]) {
          vec[vec.size() - 1].second++;
        } else {
          if (str[i] == 'A') {
            vec.push_back(make_pair(a, 1));
          } else {
            vec.push_back(make_pair(b, 1));
          }
        }
      }
    }
    int ans = str.size();
    int value = 0;
    if (vec[vec.size() - 1].first > p && vec[vec.size() - 1].second >= 2) {
      cout << ans << endl;
      continue;
    }
    ans++;
    for (int i = vec.size() - 1; i >= 0; i--) {
      if (i == vec.size() - 1) {
        if (vec[vec.size() - 1].second == 1) {
          ans = ans - 1;
          continue;
        }
      }
      if (value <= p) {
        value = value + vec[i].first;
        ans = ans - vec[i].second;
        if (value > p) {
          ans = ans + vec[i].second;
          break;
        }
      }
    }
    cout << ans << endl;
  }
}
