/* -*- coding: utf-8 -*- * * 1894.cc: No.1894 Delete AB - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d%s", &n, s); string t; for (int i = 0; i < n; i++) { if (s[i] == 'A') t.push_back('A'); else { while (! t.empty() && t.back() == '-') t.pop_back(); if (! t.empty() && t.back() == 'A') t.back() = '-'; else t.push_back('B'); } } for (auto c: t) { if (c == '-') putchar('A'), putchar('B'); else putchar(c); } putchar('\n'); } return 0; }