A keylogger was installed on the computer Gangsan uses, and it recorded, in order, every key he typed into a password field.
Because the keylogger records every key the user presses, you can recover the real password from that log even when Gangsan pressed arrow keys or backspace.
Given the keys Gangsan pressed in the password field, write a program that determines the password that was ultimately entered. The keys Gangsan can press are only uppercase letters, lowercase letters, digits, backspace, and arrow keys.
The first line contains the number of test cases. Each test case is a single line containing a string of length $L$, listing the keys pressed in order. ($1 \le L \le 1{,}000{,}000$)
Each character of the string is processed as follows.
-: Backspace. If there is a character immediately to the left of the cursor, delete it. (If there is none, nothing happens.)<: Move the cursor one position to the left. If it is already at the leftmost position, it does not move.>: Move the cursor one position to the right. If it is already at the rightmost position, it does not move.For each test case, print the password on its own line. The length of the password is always at least 1.