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

Your task is to write a program that prints the result screen after being executed various orders. In particular the possible orders are:

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 n0n\ge 0 (the total number of cases to do). Each case consists of a line with the natural m0m\ge 0 (the number of orders to execute) followed by mm 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|<106|x|<10^6 y |y|<106|y|<10^6.

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>0n>0 the output must exactly have 10n+(n1)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