#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
void solve() {
  long long int a, b, p;
  cin >> a >> b >> p;
  string s;
  cin >> s;
  long long int cnt = 0;
  vector<pair<int, int> > v;
  char tofind;
  if (s[0] == 'A') {
    tofind = 'B';
  } else
    tofind = 'A';
  for (int i = 1; i < s.length(); i++) {
    if (i == s.length() - 1 && s[i] != tofind && tofind == 'A') {
      cnt += b;
      v.push_back({b, i});
    }
    if (i == s.length() - 1 && s[i] != tofind && tofind == 'B') {
      cnt += a;
      v.push_back({a, i});
    }
    if (tofind == 'A' && s[i] == 'A') {
      cnt += b;
      v.push_back({b, i});
      tofind = 'B';
    }
    if (tofind == 'B' && s[i] == 'B') {
      cnt += a;
      v.push_back({a, i});
      tofind = 'A';
    }
  }
  if (cnt <= p) {
    cout << 1;
  } else {
    for (int i = 0; i < v.size(); i++) {
      cnt = cnt - v[i].first;
      if (cnt <= p) {
        cout << v[i].second + 1;
        break;
      }
    }
  }
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
}
