ed

Consider a text made up of only lowercase English alphabet letters. We can execute the following editing operations on this text:
1. L (the cursor moves one position to the left; if the cursor is at the beginning of the text this operation has no effect).
2. R (the cursor moves one position to the right; if the cursor is at the end of the text this operation has no effect).
3. B (deletes the character left of the cursor; if the cursor is at the beginning of the text this operation has no effect).
4. I<sequence> (inserts the sequence of lowercase letters specified after letter I at the current cursor position)
5. D<nr> (deletes, starting with the current position of the cursor, nr characters; if the number of characters existing from the current position of the cursor to the end of the row is < nr, all the existing characters from the current position of the cursor to the end of the row will be deleted).
Initially, the cursor is located at the end of the text (after the last character in the text).

Task

Write a program that applies to a text a given sequence of editing operations and displays the resulting text.

Input Data

Input file ed.in contains on the first line the given text. The second line contains a positive integer N, which represents the number of editing operations. The following N lines contain the N editing operations (one operation per line), in the order in which they have to be executed.

Output Data

Output file ed.out will contain a single line with the text obtained after the execution, in order, of the N editing operations.

Constraints and Statements

Example
ed.in ed.out

qwerty
10
L
L
D3
L
B
R
Ibb
L
Iaaa
D2

qwarbb

Time limit: 0.2 seconds/test

prof. Emanuela Cerchez
"Grigore Moisil" Iaşi IT High School
Contact:emanuela.cerchez@gmail.com