#include <bits/stdc++.h>
long long aa[100001], d[100001];
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    auto st = s[0];
    memset(d, 0, sizeof(d));
    memset(aa, 0, sizeof(aa));
    for (int i = 0; s[i]; i++) {
      if (s[i] != st) {
        if (s[i] == 'B')
          aa[i] = a;
        else
          aa[i] = b;
        st = s[i];
      }
    }
    if (s[s.size() - 1] == s[s.size() - 2]) {
      if (s[s.size() - 1] == 'A') {
        aa[s.size() - 1] = a;
      } else {
        aa[s.size() - 1] = b;
      }
    }
    for (int i = 0; s[i]; i++) {
      if (i)
        d[i] = d[i - 1] + aa[i];
      else
        d[0] = aa[0];
    }
    bool flag = false;
    if (d[s.size() - 1] <= p) {
      cout << "1\n";
      continue;
    }
    for (int i = 0; i < s.size(); i++) {
      if (d[s.size() - 1] - d[i] <= p) {
        flag = true;
        cout << i + 1 << '\n';
        break;
      }
    }
    if (!flag) cout << s.size() << '\n';
  }
}
