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

public class Main{

    private static int n;
    private static char[][] display;
    private static char[][] temp;

    private static BufferedReader sc;


    public static void main(String[] args) throws IOException {


        sc = new BufferedReader(new InputStreamReader(System.in));

        String line;
        while ((line = sc.readLine()) != null) {

            n = Integer.parseInt(line);


            display = new char[n][n];
            temp = new char[n][n];
            String input;

            for (int i = 0; i < n; i++) {
                input = sc.readLine();
                for (int j = 0; j < n; j++) {

                    display[i][j] = input.charAt(j);
                    temp[i][j] = input.charAt(j);

                }


            }
            input = sc.readLine();
            String[] digits = input.split(" ");

            for (int i = 0; i < digits.length; i++) {

                char command = digits[i].charAt(0);
                doCommand(command);

                for (int x = 0; x < n; x++) {
                    for (int j = 0; j < n; j++) {
                        display[x][j] = temp[x][j];
                    }

                }
                //printDisplay(display);

            }
            printDisplay(display);


        }



    }


    private static void doCommand(char command) {

        switch (command) {

            case '<':
                rotateLeft();
                break;
            case '>':
                rotateRight();
                break;

            case '-':
                flipHorizontal();
                break;
            case '|':
                flipVertical();
                break;
            case '\\':
                flipDiagonal();
                break;
            case '/':
                flipAntidiagonal();
                break;

        }


    }


    private static void rotateLeft() {


        char[] rotationChars = {'o', 'x', '-', '|', '\\', '/', 'v', '^', '>', '<'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {
                int symbol = getInt(display[i][j]);
                temp[n - 1 - j][i] = rotationChars[symbol];
            }

        }


    }
    private static void rotateRight() {


        char[] rotationChars = {'o', 'x', '-', '|', '\\', '/', '^', 'V', '<', '>'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {

                int symbol = getInt(display[i][j]);
                temp[j][n-1-i] = rotationChars[symbol];
            }


        }
    }

    private static void flipHorizontal() {


        char[] rotationChars = {'o', 'x', '|', '-', '\\', '/', '>', '<', '^', 'v'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {

                int symbol = getInt(display[i][j]);
                temp[n - 1 - i][j] = rotationChars[symbol];
            }

        }

    }

    private static void flipVertical() {


        char[] rotationChars = {'o', 'x', '|', '-', '\\', '/', '>', '<', 'v', '^'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {
                int symbol = getInt(display[i][j]);
                temp[i][n - 1 - j] = rotationChars[symbol];
            }

        }
    }


    private static void flipDiagonal() {


        char[] rotationChars = {'o', 'x', '-', '|', '/', '\\', '^', 'v', '>', '<'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {
                int symbol = getInt(display[i][j]);
                temp[j][i] = rotationChars[symbol];
            }

        }
    }

    private static void flipAntidiagonal() {


        char[] rotationChars = {'o', 'x', '-', '|', '/', '\\', 'v', '^', '<', '>'};

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {

                int symbol = getInt(display[i][j]);
                temp[n - 1 - j][n - 1 - i] = rotationChars[symbol];

            }


        }
    }


    private static int getInt(char symbol) {

        switch (symbol) {

            case 'o':
                return 0;

            case 'x':
                return 1;

            case '|':
                return 2;

            case '-':
                return 3;

            case '/':
                return 4;

            case '\\':
                return 5;

            case '<':
                return 6;

            case '>':
                return 7;
            case 'v':
                return 8;
            case '^':
                return 9;
            default:
                return -1;
        }

    }

    private static void printDisplay(char[][] display) {


        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {

                System.out.print(display[i][j]);


            }
            System.out.println();
        }
    }



}
