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

public class Main {

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

        int count = 0;

        while (true)
        {
            String tmp = in.readLine();
            if(tmp == null) break;

            StringTokenizer stringTokenizerInitial = new StringTokenizer(tmp);

            int M = Integer.parseInt(stringTokenizerInitial.nextToken());
            int num = Integer.parseInt(stringTokenizerInitial.nextToken());

            String[][] picture = new String[M][M];

            for(int i = 0; i<M; i++){
                for(int j = 0; j<M; j++){
                    picture[i][j] = ".";
                }
            }



            for (int i = 0; i < num; i++){
                StringTokenizer stringTokenizer = new StringTokenizer(in.readLine());
                int S = Integer.parseInt(stringTokenizer.nextToken());
                int x = Integer.parseInt(stringTokenizer.nextToken());
                int y = Integer.parseInt(stringTokenizer.nextToken());
                int Shead = S;
                if(S == 0){
                    if((y<M && y>=0) && (x>-2 && x<M+1)){
                        for(int l = 0; l<3; l++){
                            if(x-1+l>=0 && x-1+l<M){
                                if(l==0){
                                    picture[y][x-1+l] = "_";
                                }else if(l==1){
                                    picture[y][x-1+l] = "o";
                                }else if(l==2){
                                    picture[y][x-1+l] = "_";
                                }
                            }
                        }
                    }
                }else{
                    if(y>=M)continue;
                    if((y<M && y>=0) && (x>-2 && x<M+1)){
                        for(int l = 0; l<3; l++){
                            if(x-1+l>=0 && x-1+l<M){
                                if(l==0){
                                    picture[y][x-1+l] = "_";
                                }else if(l==1){
                                    picture[y][x-1+l] = "|";
                                }else if(l==2){
                                    picture[y][x-1+l] = "_";
                                }
                            }
                        }
                    }

                    int SaboveGround = 0;
                    if(y<0){
                        SaboveGround = S+y;
                        if(SaboveGround>=0){
                            for(int j=0; j<M; j++){
                                SaboveGround--;
                                for(int l = 0; l<3; l++){
                                    if(x-1+l>=0 && x-1+l<M){
                                        if(l==0){
                                            picture[j][x-1+l] = "/";
                                        }else if(l==1){
                                            picture[j][x-1+l] = "|";
                                        }else if(l==2){
                                            picture[j][x-1+l] = "\\";
                                        }
                                    }
                                }
                                if(SaboveGround<=0)break;
                            }
                        }
                    }else{
                        for(int j=y+1; j<M; j++){
                            S--;
                            for(int l = 0; l<3; l++){
                                if(x-1+l>=0 && x-1+l<M){
                                    if(l==0){
                                        picture[j][x-1+l] = "/";
                                    }else if(l==1){
                                        picture[j][x-1+l] = "|";
                                    }else if(l==2){
                                        picture[j][x-1+l] = "\\";
                                    }
                                }
                            }
                            if(S==0)break;
                        }
                    }



                    /*
                    int SaboveGround = 0;
                    if(y<0){
                        SaboveGround = S+y;
                    }else{
                        SaboveGround = S;
                    }

                    if(y<M-1 && (x>-2 && x<M+1)){

                        if(SaboveGround>0){
                            for(int j=0; j<SaboveGround; j++){
                                if(y>=0){

                                    if(y+j>=M)break;
                                    for(int l = 0; l<3; l++){
                                        if(x-1+l>=0 && x-1+l<M){
                                            if(l==0){
                                                picture[y+j][x-1+l] = "/";
                                            }else if(l==1){
                                                picture[y+j][x-1+l] = "|";
                                            }else if(l==2){
                                                picture[y+j][x-1+l] = "\\";
                                            }
                                        }
                                    }

                                }else{

                                    if(j>=M)break;
                                    for(int l = 0; l<3; l++){
                                        if(x-1+l>=0 && x-1+l<M){
                                            if(l==0){
                                                picture[j+1][x-1+l] = "/";
                                            }else if(l==1){
                                                picture[j+1][x-1+l] = "|";
                                            }else if(l==2){
                                                picture[j+1][x-1+l] = "\\";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }*/


                    int head = y+Shead+1;
                    if((head>=0 && head<M) && (x>=0 && x<M)){
                        picture[head][x] = "^";
                    }

                }


            }
            printPicture(picture);
            count++;

        }
    }

    public static void printPicture(String[][] picture){
        for(int i = picture.length-1; i>=0; i--){
            if(i==picture.length-1){
                System.out.print("*");
                for(int j = 0; j<=picture.length-1; j++){
                    System.out.print("*");
                }
                System.out.print("*");
                System.out.println();
            }

            System.out.print("*");
            for(int j = 0; j<=picture.length-1; j++){
                System.out.print(picture[i][j]);
            }
            System.out.print("*");

            System.out.println();
            if(i==0){
                System.out.print("*");
                for(int j = 0; j<=picture.length-1; j++){
                    System.out.print("*");
                }
                System.out.print("*");
                System.out.println();
                System.out.println();
            }


        }
    }
}
