166. Editor

time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard
output: standard



You are to write a simple text editor. This editor must supply next commands:

  1. english lowercase letters or spaces: insert this letter in the current position of the cursor.
  2. L: move cursor one position left. If current position in the beginning of the line, cursor mustn't move.
  3. R: move cursor one position right. If the current position if after the end of the line, cursor must go beyond this end. If an english lowercase letter or space follows in command line, additional spaces must be added to the text.
  4. U: move cursor a line up. If the current line is the first, cursor mustn't move.
  5. D: move cursor a line down. If the current line is last, cursor mustn't move.
  6. N: a new line must be added after the current. The part of the current line, which goes after the cursor position, must go on the new line. The cursor must go on the first position of the new line.
  7. E: a cursor must move to a position after the end of the curent line.
  8. H: a cursor must move to the first position of the current line.
  9. X: current symbol must be deleted. The remaining part of the line must shift left. If the current position is after the end of the current line, additional spaces must be added to the current line and the next line must be attached to the current line; if the current position is after the end of the last line, nothing must happen.
  10. B: the symbol before the the cursor must be deleted and the remaining part of the line must shift left. If the current position if after the end of the line, cursor must shift left one position. If the current symbol is the first of the line, then current line must be attached to the previous and remaining part must shift up; if the current symbol is the first symbol of the first line, nothing must happen.
  11. Q: the editor must finish the work.


The editor starts from the blank file.

It is guaranted that in any moment while working length of each string does not exceed 1000 chars, and total number of commands does not exceed 20480.

Input
On the input there is the only line --- the list of commands of the editor.

Output
Write to the output the result of working of the editor. The EOLn (symbols with ASCII numbers 13 and 10) chars must be only between lines generated by editor (NOT after the last string!)

Sample test(s)

Input
lineRoUNLLLLline dDDDNline tline cLLLLLLNEUULLXRRRBXHBBHBBBBQsome left output

Output
line lined line t
line c
[submit]
[forum]

Author:NNSU #2 team
Resource:
Date:











Server time: 2017-11-23 19:44:19Online Contester Team © 2002 - 2016. All rights reserved.