You have been hired to program the manager of windows of the new
operating system preferred by everybody, Windows Vista-ZO. The new
screeen of the new Windows is a grid plane virtually infinite; the
visible part of the screen is a rectangle of 40 by 10 blocks. The grid
that takes the corner at the bottom on the left of the visible part has
coordinates
,
the one at the top on the right has coordinates
.
The blocks of the screen can be empty (it is marked with the character
.) or taken by a window. Initially the screen is empty and
the cursor is in
.
The windows are painted one over another one. A window takes (overwrites) the block that may be occupied by a previous window. Each window is a rectangular that must be painted in the following way (the instance of the next page make easier the comprehension):
The four corners of the frame of the window have the characters
#.
The vertical walls of the frame have the characters
!.
The top wall of the frame (title bar) has the characteres
=.
The wall of the bottom of the frame has the characters
-.
Inside the window is full of one of the characters
1, 2,
,
9, 0: in particular, inside the
-th
window is full of the character
,
that is, the remainder of the division
by
Your task is to write a program that prints the result screen after being executed various orders. In particular the possible orders are:
MOV <x> <y>: the position of the cursor
changes to
.
MOVREL <rx> <ry>: the position of the
cursor is increased in
(for instance, if
and
,
the coordinate
of the cursor is not modified, and the coordinate
of the cursor is decreased in 3 units).
DRAW <sx> <sy>: paints a window, which
top corner on the left is in the position of the cursor, of
columns and
rows. The whole window is such that
and
.
The position of the cursor is not modified.
The cursor can move out of the screen; the painted windows do not have always to start to be painted inside the screen, and do not have always to fit inside the screen.
The first line contains the natural (the total number of cases to do). Each case consists of a line with the natural (the number of orders to execute) followed by lines, each one of them contains an order to execute, following the described format previously. During the paint orders, the coordinates of the cursor always fulfil y .
Your program must print 10 lines of 40 characters for each case to
do. Separe two cases with a line that contains only a comma
(,). Therefore, if
the output must exactly have
lines.
Input
0
Output
Input
1 0
Output
........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................
Input
2 1 DRAW 40 10 0
Output
#======================================# !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! !11111111111111111111111111111111111111! #--------------------------------------# , ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ........................................
Input
2 11 DRAW 10 10 MOVREL 3 -3 DRAW 10 10 MOVREL 3 -3 DRAW 10 10 MOVREL 3 -3 DRAW 10 10 MOVREL 3 -3 DRAW 10 10 MOV 2 7 DRAW 6 6 22 MOVREL 500000 500000 DRAW 10 10 DRAW 100 100 DRAW 4 4 DRAW 10 10 MOVREL 0 0 MOVREL -500000 -500000 DRAW 10 10 MOVREL 4999990 500010 DRAW 100 40 MOV -2 12 DRAW 6 6 MOV 36 12 DRAW 6 6 MOV -2 3 DRAW 6 6 MOV 36 3 DRAW 6 6 MOVREL -20 7 DRAW 6 6 MOVREL 10 0 DRAW 3 3
Output
#========#.............................. !11111111!.............................. !1#====#1!.............................. !1!6666!====#........................... !1!6666!2222!........................... !1!6666!2222!........................... !1!6666!=======#........................ !1#----#3333333!........................ !11!22!33333333!........................ #--!22!33#========#..................... , 777!=====#......!1111!....!2!.......!888 777!55555!......!1111!....#-#.......!888 ---#55555!......!1111!..............#--- !55555555!......!1111!.................. !55555555!......#----#.................. !55555555!.............................. ===#55555!..........................#=== 999!55555!..........................!000 999!55555!..........................!000 999!-----#..........................!000