import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Forest {
    static int size;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        String line;
        boolean l = false;
        while (true) {
            if (l) {
                System.out.println();
            }
            l = true;
            line = br.readLine();
            if (line == null) break;
            String[] parts = line.split(" ");
            size = Integer.parseInt(parts[0]);
            int count = Integer.parseInt(parts[1]);

            char[][] map = new char[size][size];
            for (int i = 0; i < size; i++) {
                for (int j = 0; j < size; j++) {
                    map[i][j] = '.';
                }
            }

            for (int i = 0; i < count; i++) {
                String[] instruction = br.readLine().split(" ");
                draw(instruction, map);
            }

            for (int j = 0; j < size + 2; j++) {
                System.out.print("*");
            }
            System.out.println();

            for (int i = 0; i < size; i++) {
                System.out.print("*");
                for (int j = 0; j < size; j++) {
                    System.out.print(map[i][j]);
                }
                System.out.println("*");
            }
            for (int j = 0; j < size + 2; j++) {
                System.out.print("*");
            }
            System.out.println();
        }

        br.close();
    }

    static void draw(String[] args, char[][] map) {
        int height = Integer.parseInt(args[0]);
        int x = Integer.parseInt(args[1]);
        int y = Integer.parseInt(args[2]);

        drawPixel(map, x-1, y, '_');
        drawPixel(map, x+1, y, '_');
        if (height == 0) {
            drawPixel(map, x, y, 'o');
        } else {
            drawPixel(map, x, y, '|');
            drawPixel(map, x, y+height+1, '^');
            for (int i = 1; i <= height; i++) {
                drawPixel(map, x-1, y+i, '/');
                drawPixel(map, x, y+i, '|');
                drawPixel(map, x+1, y+i, '\\');
            }
        }
    }

    static void drawPixel(char[][] map, int x, int y, char p) {
        if (inside(x, y)) {
            map[size-y-1][x] = p;
        }
    }

    static boolean inside(int x, int y) {
        return x >= 0 && x < size && y >= 0 && y < size;
    }
}
