#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MM = 1e5 + 5;
int cost[MM];
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    int a, b, p;
    cin >> a >> b >> p;
    cin >> s;
    int len = s.size();
    int zz = len - 2;
    int cos = 0;
    while (zz >= 0) {
      if (zz == 0) {
        if (s[zz] == 'A')
          cos += a;
        else
          cos += b;
        if (cos <= p) break;
      } else if (s[zz - 1] == s[zz])
        ;
      else {
        if (s[zz] == 'A')
          cos += a;
        else
          cos += b;
      }
      if (cos > p) {
        while (zz < len && s[zz + 1] == s[zz]) zz++;
        if (s[zz + 1] != '\0') zz++;
        cout << zz + 1 << endl;
        zz = -10;
        break;
      }
      zz--;
    }
    if (zz != -10) cout << 1 << endl;
  }
  return 0;
}
