#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, p;
    cin >> a >> b >> p;
    string s;
    cin >> s;
    int length = s.length();
    vector<int> v_b;
    v_b.clear();
    char last_c = '?';
    for (int i = 0; i < length; ++i) {
      char c = s[i];
      if (c != last_c) {
        v_b.push_back(i + 1);
        last_c = c;
      }
    }
    if (v_b.size() == 0) {
      if (s[0] = 'A')
        p -= a;
      else
        p -= b;
      if (p < 0)
        cout << length << endl;
      else
        cout << "1" << endl;
    } else {
      vector<int> v_p = v_b;
      int v_b_size = v_b.size();
      for (int i = v_b_size - 1; i >= 0; --i) {
        if (i == v_b_size - 1) {
          if (v_b[i] == length) {
            v_p[i] = 0;
            continue;
          }
          if (s[v_b[i] - 1] == 'B') {
            v_p[i] = b;
          } else
            v_p[i] = a;
        } else {
          if (s[v_b[i] - 1] == 'B') {
            v_p[i] = v_p[i + 1] + b;
          } else {
            v_p[i] = v_p[i + 1] + a;
          }
        }
      }
      int on_foot_pos = -1;
      for (int i = v_b_size - 1; i >= 0; --i) {
        if (v_p[i] > p) {
          if (i == v_b_size - 1) {
            on_foot_pos = length;
          } else {
            on_foot_pos = v_b[i + 1];
          }
          break;
        }
      }
      if (on_foot_pos == -1)
        cout << "1" << endl;
      else
        cout << on_foot_pos << endl;
    }
  }
  return 0;
}
