#include using namespace std; using ll = long long; using pii = pair; void solve() { int n; cin >> n; string s; cin >> s; if(n == 1) { cout << "B\n"; return ; } string s2 = s.substr(0, 2); if(s2 == "AB") { cout << "BB"; int idx = 2; while(idx < n && s[idx] == 'A') { cout << s[idx]; idx++; } while(idx < n && s[idx] == 'B') { cout << 'A'; idx++; } cout << s.substr(idx) << "\n"; } else if(s2 == "BA" || s2 == "AA") { cout << "BB"; int idx = 2; while(idx < n && s[idx] == 'B') { cout << "A"; idx++; } cout << s.substr(idx) << "\n"; } else if(s2 == "BB") { cout << "BB" << s.substr(2) << "\n"; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; cin >> t; while(t--) solve(); } // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("trapv") // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // shuffle(a.begin(), a.end(), rng); // uniform_int_distribution(l, r)(rng); // [l, r] // freopen(".in", "r", stdin); // freopen(".out", "w", stdout);