Painting windows P86495


Statement
 

pdf   zip

html

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|<106 y |y|<106.

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.

Public test cases
  • 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
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++