#!/usr/bin/python

def draw(pic, X, Y, C):
    if X >= 0 and X < len(pic[0]) and Y >= 0 and Y < len(pic):
        pic[X][Y] = C


try:
    while True:
        M, N = map(int, input().split(" "))
        pic = [['.' for _ in range(M)] for _ in range(M)]
        for _ in range(N):
            S, X, Y = map(int, input().split(' '))
            draw(pic, Y, X-1, '_')
            draw(pic, Y, X+1, '_')
            if S == 0:
                draw(pic, Y, X, 'o')
            elif X >= -1 and X < M+1:
                draw(pic, Y, X, '|')
                for i in range(max(-2,Y+1), S+Y+1):
                    draw(pic, i, X, '|')
                    draw(pic, i, X-1, '/')
                    draw(pic, i, X+1, '\\')
                    if Y+i-2 > M:
                        break;
                draw(pic, i+1, X, '^')
        print((M+2) * '*')
        for row in reversed(pic):
            print('*', ''.join(row), '*', sep='')
        print((M+2) * '*')
        print('')

except EOFError:
    pass
