/* Copyright (C) 2009 Igor V. Burago */

#include <cassert>
#include <fstream>
#include <vector>

using namespace std;


int size;
vector< vector<char> > field;
char type;
char subtype;
int foldLine;


inline bool isValid(const int row, const int col)
{
    return 0 <= row && row < size && 0 <= col && col < size;
}


char symbol(int cell)
{
    static const char *Symbols = "~<v`>?\'W^,?Z.MK#";
    assert(0 <= cell && cell <= 15);
    cell = Symbols[cell];
    assert(cell != '?');
    return cell;
}


char fold(const char cell)
{
    if (type == '/')
    {
        if (subtype == 'u')
            return ((cell & 2) >> 1) | ((cell & 4) << 1) | (cell & 1) | (cell & 8);
        else
            return ((cell & 1) << 1) | ((cell & 8) >> 1) | (cell & 2) | (cell & 4);
    }
    else
    {
        if (subtype == 'u')
            return ((cell & 1) << 3) | ((cell & 2) << 1) | (cell & 4) | (cell & 8);
        else
            return ((cell & 4) >> 1) | ((cell & 8) >> 3) | (cell & 1) | (cell & 2);
    }
}


char reflect(const char cell)
{
    if (type == '/')
        return ((cell & 1) << 1) | ((cell & 2) >> 1) | ((cell & 4) << 1) | ((cell & 8) >> 1);
    else
        return ((cell & 1) << 3) | ((cell & 8) >> 3) | ((cell & 2) << 1) | ((cell & 4) >> 1);
}


void transform(const int line, char (*change)(char))
{
    const int nextRowOffset = (subtype == 'u' ? 1 : -1);
    const int nextColOffset = (((type != '/') + (subtype != 'u')) % 2 == 0 ? -1 : 1);
    int row = (nextRowOffset < 0 ? size - 1 : 0);
    int col = (nextColOffset < 0 ? line - 1 : size - line);

    const int imageRowOffset = (foldLine - line) * nextRowOffset;
    const int imageColOffset = (line - foldLine) * nextColOffset;
    while (isValid(row, col))
    {
        const char cell = field[row][col];
        field[row][col] = 0x0;
        field[row + imageRowOffset][col + imageColOffset] |= change(cell);
        row += nextRowOffset;
        col += nextColOffset;
    }
}


int main()
{
    ifstream input("input.txt");
    ofstream output("output.txt");

    int commandsCount;
    assert(input >> size >> commandsCount);
    assert(1 <= size && size <= 100);
    assert(0 <= commandsCount && commandsCount <= 4 * size - 2);

    field.resize(size);
    for (int row = 0; row < size; ++row)
        field[row].resize(size, 0xF);

    for (int command = 0; command < commandsCount; ++command)
    {
        assert(input >> type >> subtype >> foldLine);
        assert(type == '/' || type == '\\');
        assert(subtype == 'l' || subtype == 'u');
        assert(1 <= foldLine && foldLine <= size);

        for (int line = 1; line < foldLine; ++line)
            transform(line, reflect);
        transform(foldLine, fold);
    }

    for (int row = 0; row < size; ++row)
    {
        for (int col = 0; col < size; ++col)
            output << symbol(field[row][col]);
        output << endl;
    }

    return 0;
}
