LCD Extravaganza 

Liquid Crystal Developers (LCD) is a top-notch manufacturer of alarm clocks. Alarm clocks are one of the few things that have not changed dramatically since their invention. The market department at LCD has devised a plan to manufacture customizable alarm clocks in order to attract more customers. The new alarm clocks could be programmed by the owner to display digits with heterogeneous sizes, that is, display amplified versions of the traditional digits according to the user's preference.


A traditional digit, or simply a digit, is a nonnegative integer d ( 0 $ \leq$ d $ \leq$ 9). A digit is displayed in a 3 x 3 grid consisting of dots (decimal ASCII code 46), underscores (decimal ASCII code 95), and bars (decimal ASCII code 124), as depicted in the following figure:

          ._.   ...   ._.   ._.   ...   ._.   ._.   ._.   ._.   ._.
          |.|   ..|   ._|   ._|   |_|   |_.   |_.   ..|   |_|   |_|
          |_|   ..|   |_.   ._|   ..|   ._|   |_|   ..|   |_|   ._|
                                                                   
           0     1     2     3     4     5     6     7     8     9

An amplified digit is a pair (d, f ) consisting of a digit d and a positive integer factor f ( 0 $ \leq$ d $ \leq$ 9, f $ \geq$ 1). An amplified digit (d, f ) is displayed in a grid with (2 . f )+ 1 rows and f + 2 columns. Each such a grid consists of underscores, dots, and bars, in which underscores and bars are expanded horizontally and vertically, respectively, by a factor of f with respect to the display of digit d. Dots are used to fill any space in the grid not corresponding to an underscore or a bar. As an example, consider the following figure displaying five amplified digits:

                                                         .______. 
                                                         |.......
                                  ._____.                |.......
                                  |......                |.......
           ......                 |......                |.......
           |....|                 |......                |.......
           |....|      .....      |......                |______.
           |....|      ....|      |_____.                |......|
           |____|      ....|      ......|      .__.      |......|
           .....|      ....|      ......|      ...|      |......|
           .....|      ....|      ......|      .__|      |......|
           .....|      ....|      ......|      |...      |......|
           .....|      ....|      ._____|      |__.      |______|
                                                                 
           (4,4)       (1,3)       (5,5)       (2,2)      (6,6)

The new alarm clocks display sequences of amplified digits. The amplified digits in a display are aligned vertically with respect to their bottom rows. Moreover, in the display, each two consecutive amplified digits are separated by a column of dots and any space that does not contain an underscore or a bar is represented by a dot. The following figure displays the sequence (4, 4),(1, 3),(5, 5),(2, 2),(6, 6) of amplified digits:

                     ...........................______.
                     ..........................|.......
                     .............._____.......|.......
                     .............|............|.......
                     .............|............|.......
                     |....|.......|............|.......
                     |....|.......|............|______.
                     |....|.....|.|_____.......|......|
                     |____|.....|.......|..__..|......|
                     .....|.....|.......|....|.|......|
                     .....|.....|.......|..__|.|......|
                     .....|.....|.......|.|....|......|
                     .....|.....|.._____|.|__..|______|

As a member of the programming department at LCD, you have been assigned the implementation of an algorithm for sampling the display of the new alarm clocks.

Input 

The input consists of several test cases. The first line in a test case contains a positive integer N ( 1 $ \leq$ N $ \leq$ 104), representing the number of amplified digits in the display. Each one of the following N lines contains two blank-separated integers di and fi ( 0 $ \leq$ di $ \leq$ 9, 1 $ \leq$ fi $ \leq$ 105 for each 1 $ \leq$ i $ \leq$ N), representing an amplified digit (di, fi). The next line contains a nonnegative integer M ( 0 $ \leq$ M $ \leq$ 104), representing the number of samples for the display. Then M lines follow, each containing two blank-separated integers xj and yj ( 0 $ \leq$ xj < c, 0 $ \leq$ yj < r for each 1 $ \leq$ j $ \leq$ M), representing a sample. The positive integers c and r denote the total number of columns and rows in the displayed sequence of amplified digits, respectively. The last test case is followed by a line containing a single zero value.

Output 

For each test case with N displayed amplified digits (d1, f1), ..., (dN, fN) and M samples (x1, y1), ..., (xM, yM), M lines must be printed, each containing either an underscore, a dot, or a bar. The j-th line in the output ( 1 $ \leq$ j $ \leq$ M) must identify the character at column xj and row yj in the display of (d1, f1),...,(dN, fN). Coordinate (0, 0) identifies the character in the leftmost column and bottom row (i.e., a coordinate represents a point in the first quadrant of the integer Cartesian coordinate system with origin in the leftmost column and bottom row).

Sample Input 

5
4 4
1 3
5 5
2 2
6 6
7
5 0
6 0
13 5
33 12
32 12
5 7
5 8
3
1 2
1 1
7 4
4
13 8
13 7
0 8
7 1
0

Sample Output 

|
.
|
.
_
|
.
_
.
.
|