#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   constexpr int N = 2e5 + 5;   int t, a, b, p;   string s;   void Solve() {     cin >> t;     while (t--) {       cin >> a >> b >> p >> s;       s.pop_back();       vector<ll> suf;       suf.resize(s.size());       char last =  0 ;       for (int i = s.size() - 1; i >= 0; i--) {         if (s[i] != last) suf[i] = (s[i] ==  A  ? a : b);         last = s[i];       }       for (int i = suf.size() - 2; i >= 0; i--) suf[i] += suf[i + 1];       int id = 0;       while (id < suf.size() && suf[id] > p) id++;       cout << id + 1 <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     Solve();     return 0;   }   