CF1907B.YetnotherrokenKeoard

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

YetnotherrokenKeoard

Polycarp has a problem — his laptop keyboard is broken.

Now, when he presses the 'b' key, it acts like an unusual backspace: it deletes the last (rightmost) lowercase letter in the typed string. If there are no lowercase letters in the typed string, then the press is completely ignored.

Similarly, when he presses the 'B' key, it deletes the last (rightmost) uppercase letter in the typed string. If there are no uppercase letters in the typed string, then the press is completely ignored.

In both cases, the letters 'b' and 'B' are not added to the typed string when these keys are pressed.

Consider an example where the sequence of key presses was "ARaBbbitBaby". In this case, the typed string will change as follows: "" A\xrightarrow{\texttt{A}} "A" R\xrightarrow{\texttt{R}} "AR" a\xrightarrow{\texttt{a}} "ARa" B\xrightarrow{\texttt{B}} "Aa" b\xrightarrow{\texttt{b}} "A" b\xrightarrow{\texttt{b}} "A" i\xrightarrow{\texttt{i}} "Ai" t\xrightarrow{\texttt{t}} "Ait" B\xrightarrow{\texttt{B}} "it" a\xrightarrow{\texttt{a}} "ita" b\xrightarrow{\texttt{b}} "it" y\xrightarrow{\texttt{y}} "ity".

Given a sequence of pressed keys, output the typed string after processing all key presses.

Input

The first line of the input data contains an integer tt (1t10001 \le t \le 1000), the number of test cases in the test.

The following contains tt non-empty lines, which consist of lowercase and uppercase letters of the Latin alphabet.

It is guaranteed that each line contains at least one letter and the sum of the lengths of the lines does not exceed 10610^6.

Output

For each test case, output the result of processing the key presses on a separate line. If the typed string is empty, then output an empty line.

Samples

12
ARaBbbitBaby
YetAnotherBrokenKeyboard
Bubble
Improbable
abbreviable
BbBB
BusyasaBeeinaBedofBloomingBlossoms
CoDEBARbIES
codeforces
bobebobbes
b
TheBBlackbboard
ity
YetnotherrokenKeoard
le
Imprle
revile

usyasaeeinaedofloominglossoms
CDARIES
codeforces
es

helaoard

在线编程 IDE

建议全屏模式获得最佳体验