High School Programming League 2011/2012

More Caterpillars

Problem code: HS11MCTP

As we mentioned previously, there are two types of caterpillars.

Your new task is to print several caterpillars which are relaxing, lying on a square.

Input

First two integers: c, 1<=c<=100, denoting the number of caterpillars and n, 10<=n<=100 the size of the square. Each of the next lines consists of one letter (V, for vertical caterpillars or H for horizontal ones, an integer 3<=n<=20 - the caterpillar size in segments and two integers: x, y denoting the coordinates of the upper left corner of the given caterpillar.

Output

The nxn square and the caterpillars according to the description. Please consult the examples below.

Examples

Example 1

Input:
2 12
V5 1 1
H3 7 10

Output:
###.........
..#.........
###.........
#...........
###.........
..#.........
###.........
#...........
###.........
..#...#.###.
......#.#.#.
......###.##

Example 2

Input:
4 14
H3 3 1
H3 4 4
V4 2 5
V3 8 7 

Output:
..#.###.......
..#.#.#.......
..###.##......
...#.###......
.###.#.#......
...###.##.....
.###...###....
.#.......#....
.###...###....
...#...#......
.###...###....
.#.......#....
..............
..............

Scoring

By solving this problem you score 10 points.


Added by:Łukasz Kuszner
Date:2011-10-15
Time limit:1s
Source limit:50000B
Languages:All except: SED AWK
Resource:High School Programming League
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.