#include #include #include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) using m32 = atcoder::modint998244353; int main(){ int T; cin >> T; while(T --> 0){ int N; cin >> N; string S; cin >> S; string buf; for(char c : S){ if(c == 'B'){ while(buf.size() >= 2 && buf.substr(buf.size() - 2) == "AB"){ rep(t,2) buf.pop_back(); } } buf.push_back(c); } cout << buf << '\n'; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;