Painting windows

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 (0, 0), the one at the top on the right has coordinates
(39, 9). 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 (0, 9).

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 i-th window is full of the character i mod  10,
  that is, the remainder of the division i by 10

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 (x, y).

- MOVREL <rx> <ry>: the position of the cursor is increased in (rx, ry)
  (for instance, if rx = 0 and ry = −3, the coordinate x of the cursor
  is not modified, and the coordinate y 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 sx columns and sy rows. The whole
  window is such that 3 ≤ sx ≤ 40 and 3 ≤ sy ≤ 10. 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.

Input

The first line contains the natural n ≥ 0 (the total number of cases to
do). Each case consists of a line with the natural m ≥ 0 (the number of
orders to execute) followed by m 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 |x| < 10⁶ y
|y| < 10⁶.

Output

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 n > 0 the output must exactly have 10n + (n − 1) lines.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:08:52.240Z

© Jutge.org, 2006–2026.
https://jutge.org
