∧e — Erase characters to the right of, and including, the cursor column on the cursor’s row; the cursor row and column do not change∧h — Move the cursor to row 0, column 0; the image on the screen is not changed∧i — Enter insert mode (see below)∧l — Move the cursor left one column, if possible; the cursor row does not change∧o — Enter overwrite mode (see below)∧r — Move the cursor right one column, if possible; the cursor row does not change∧u — Move the cursor up one row, if possible; the cursor column does not change∧∧ — Write a circumflex (∧) at the current cursor location, exactly as if it was not a special character; this is subject to the actions of the current mode (insert or overwrite)∧## — Move the cursor to the row and column specified; # represents a decimal digit; the first # represents the new row number, and the second # represents the new column numberNo illegal control sequences will ever be sent to the terminal. The cursor cannot move outside the allowed screen locations (that is, between row 0, column 0 and row 9, column 9).
When a normal character (not part of a control sequence) arrives at the terminal, it is displayed on the terminal screen in a manner that depends on the terminal mode. When the terminal is in overwrite mode (as it is when it is first turned on), the received character replaces the character at the cursor’s location. But when the terminal is in insert mode, the characters to the right of and including the cursor’s location are shifted right one column, and the new character is placed at the cursor’s location; the character previously in the rightmost column of the cursor’s row is lost. Regardless of the mode, the cursor is moved right one column, if possible.
The input will contain multiple tests of your terminal software. Each test begins with a line containing an integer N . Following this line there will be N more lines of data, each character of which is to be treated as if it was input, in the order read, to your terminal software. There will be no tab characters in the input data, and ends of lines in the input are to be ignored. Note that blanks in the input data are normal characters to be displayed on your terminal’s screen. The last test will be followed by a single line containing the integer ‘0’. No control sequence will be split between two lines of the input data.
At the beginning of each test case you are to assume the terminal screen is clear (that is, filled with blanks), that the terminal is in overwrite mode, and that the cursor is in row 0, column 0 of the screen.
For each input test case, output a line with the case number (these are numbered sequentially starting with 1) and the screen image the way it would look at the end of processing the data in the test case. Enclose the screen image in a “box”; see the sample below for illustration of the required format.