You have a simple, line-oriented “compression” language. The language works as follows:
begin
keyword and end with the end
keyword.l
n — The n lines that follow this command are added to the output as is. The next command comes after that.r
n k — The k lines of the output which start at the nth line from the current end of the output are repeated.
Note, that if k > n, then some of the repeated lines will be the lines that were added by this command itself.
Your goal is to create a valid “compressed” document for which the output is identical to the input. Write the compressed document on the left, see the result on the right.