#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, p;
    cin >> a >> b >> p;
    int cost[2];
    cost[0] = a;
    cost[1] = b;
    string str;
    cin >> str;
    int n = str.length() - 2, i;
    i = n;
    while (i >= 0 && p - cost[str[i] - 'A'] >= 0) {
      char ch = str[i];
      while (i >= 0 && str[i] == ch) i--;
      p -= cost[ch - 'A'];
    }
    cout << i + 2 << endl;
  }
}
