Keylogger

No attempts yetTime limit1sMemory limit256 MB

Problem

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.

Input

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.
  • Any other character: part of the password, inserted at the cursor position. If the cursor is not at the end of the line, the cursor and every character to its right shift one position to the right. After the insertion, the cursor is placed to the right of the inserted character. (This character can also be deleted later with backspace.)

Output

For each test case, print the password on its own line. The length of the password is always at least 1.