Only Beautiful Versions of Brokenness

4.1

8 votes
Queue, Easy
Problem

Somnath is supposed to submit an assignment for his semester, but The Code Goddess cursed his keyboard. While typing the “HOME” and “END” keys gets pressed internally in a random manner.
Since Somnath is in a hurry and he couldn't rectify his assignment. Can you help him with recovering the original text?

Input Format
The first line consists of a single integer T.
Next T lines contains a single string S in each line containing any alphabets and underscores (no spaces) and two special symbols “<” indicating HOME button is pressed and “>” indicating END button is pressed.

Output Format
For each string S output a single line containing the rectified text.

Constraints

1 <= T <= 105
1 <= |S| <= 1000

Time Limit: 2.5
Memory Limit: 256
Source Limit:
Editor Image

?