class Tree():
    def __init__(self, h, x, y):
        self.h = h
        self.x = x
        self.y = y
    
    def paintMid(self, canvas, y, cMid, cSideL, cSideR):
        if y >= 0 and y < len(canvas):
            if self.x - 1 >= 0 and self.x - 1 <= len(canvas) - 1:
                canvas[y][self.x-1] = cSideL
            if self.x >= 0 and self.x <= len(canvas) - 1:
                canvas[y][self.x] = cMid
            if self.x + 1 >= 0 and self.x + 1 <= len(canvas) - 1:
                canvas[y][self.x+1] = cSideR 

    def buildTree(self, canvas):
        canvasH = len(canvas)
        for y in range(self.y, self.y + self.h + 2):
            if self.h == 0:
                self.paintMid(canvas, y, 'o', '_', '_')
                return
            elif y == self.y:
                self.paintMid(canvas, y, '|', '_', '_')
            elif y == self.y + self.h + 1:
                self.paintMid(canvas, y, '^', '.', '.')
            else:
                self.paintMid(canvas, y, '|', '/', '\\')

def printPicture(canvas, M):
    pic = [' ' * (M + 2) for i in range(M+2)]
    print('*' * (M + 2))
    for i in range(M):
        print("".join(['*'] + canvas[M - i - 1] + ['*']))
    print('*' * (M + 2))


def main():
    counter = 0
    canvas = [] 
    while True:
        try:
            splitline = [int(x) for x in input().split()]
            if  counter <= 0:
                M = splitline[0]
                counter = splitline[1]
                canvas = [['.' for i in range(M)] for j in range(M)]
#load tree
            else:
                counter -= 1
                h = splitline[0]
                x = splitline[1]
                y = splitline[2]   
                tree = Tree(h, x, y)
                tree.buildTree(canvas)
                if counter == 0:
                    printPicture(canvas, M)
        except EOFError:
            break
main()
