#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int sz = 1e5 + 5;
void solve() {
  int a, b, c;
  string s;
  cin >> a >> b >> c;
  cin >> s;
  int hold = 0, i;
  bool r = 0;
  s[s.size() - 1] = '@';
  for (i = s.size() - 1; i > 0; i--) {
    if (s[i] != s[i - 1]) c -= (s[i - 1] == 'B') ? b : a;
    if (c < 0) {
      cout << i + 1 << endl;
      break;
    }
  }
  if (c >= 0) cout << 1 << endl;
}
int main() {
  int n, t, hold = 0, a, b, q;
  cin >> t;
  while (t--) solve();
  return 0;
}
