import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * Created by cteam074 on 22.10.16.
 */
public class Display {

    private static boolean firstPrinted = false;

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

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/home/cteam074/IdeaProjects/CTUOpen/src/displayInput.txt"))));
        doOneTestCase(in);
    }

    private static void doOneTestCase(BufferedReader in) throws IOException {
        String line = in.readLine();
        if (line == null) {
            return;
        }
        if (firstPrinted) {
            System.out.print("\n");
        }
        int gridSize = Integer.parseInt(line);

        Character[][] grid = new Character[gridSize][gridSize];
        
        for(int i = 0; i < gridSize; i++) {
            parseLineIntoGrid(gridSize, grid[i], in);
        }

        List<Character> rotationCommands = parseCommands(in);

        Character[][] rotated = grid;

        for(Character rotation : rotationCommands) {
            rotated = rotateGrid(rotated, gridSize, rotation);
        }
        printGrid(rotated, gridSize);

        firstPrinted = true;
        
        doOneTestCase(in);
    }

    private static List<Character> deleteRedundantOperations(List<Character> operations) {
        List<Character> changingOperations = new ArrayList<>();

        for(int i = 0; i < operations.size(); i++) {
            Character current = operations.get(i);
            Character next = null;
            if (i < operations.size() -1) {
                next = operations.get(i+1);
            }
            Character optimized = deleteIfPossible(current, next).orElse(null);
            if (optimized != null) {
                changingOperations.add(optimized);
            }
        }
        return changingOperations;
    }

    private static Optional<Character> deleteIfPossible(Character first, Character second) {
        if (second == null) {
            return Optional.of(first);
        }
        if (
                (first.equals('<') && second.equals('>')) ||
                        (first.equals('>') && second.equals('<')) ||
                        (first.equals('-') && second.equals('-')) ||
                        (first.equals('|') && second.equals('|')) ||
                        (first.equals('\\') && second.equals('/')) ||
                        (first.equals('/') && second.equals('\\'))) {
            return Optional.ofNullable(null);
        }
        else if (first.equals('\\') && second.equals('|')) {
            return Optional.of('>');
        } else if (first.equals('/') && second.equals('|')) {
            return Optional.of('<');
        } else if (
                (first.equals('<') && second.equals('\\')) || (first.equals('>') && second.equals('/'))
                ) {
            return Optional.of('|');
        } else {
            return Optional.of(first);
        }
    }

    private static void parseLineIntoGrid(int numOfElements, Character[] characters, BufferedReader in) throws IOException {
        String line = in.readLine();
        for(int i = 0; i < numOfElements; i++) {
            characters[i] = line.charAt(i);
        }
    }

    private static List<Character> parseCommands(BufferedReader in) throws IOException {
        List<Character> charCommands = new ArrayList<>();

        String line = in.readLine();
        String[] commands = line.split(" ");
        for(String command : commands) {
            charCommands.add(command.charAt(0));
        }
        return charCommands;
    }


    private static void printGrid(Character[][] grid, int gridSize) {
        for(int xCoord = 0; xCoord < gridSize; xCoord++) {
            if(xCoord > 0) {
                System.out.print("\n");
            }
            for(int yCoord = 0; yCoord < gridSize; yCoord++) {
                System.out.print(grid[xCoord][yCoord]);
            }
        }
    }

    private static Character[][] rotateGrid(Character[][] grid, int gridSize, Character rotation) {
        Character[][] rotated = new Character[gridSize][gridSize];
        switch (rotation) {
            case '<' : {
                for(int xCoord = 0; xCoord < gridSize; xCoord++) {
                    for(int yCoord = 0; yCoord < gridSize; yCoord++) {
                        rotated[xCoord][yCoord] = rotateCharacter(grid[yCoord][(gridSize-1)-xCoord], rotation);
                    }
                }
                return rotated;
            }
            case '>' : {
                for(int xCoord = 0; xCoord < gridSize; xCoord++) {
                    for(int yCoord = 0; yCoord < gridSize; yCoord++) {
                        rotated[xCoord][yCoord] = rotateCharacter(grid[(gridSize-1)-yCoord][xCoord], rotation);
                    }
                }
                return rotated;
            }
            case '-' : {
                for(int xCoord = 0; xCoord < gridSize; xCoord++) {
                    for(int yCoord = 0; yCoord < gridSize; yCoord++) {
                        rotated[xCoord][yCoord] = rotateCharacter(grid[(gridSize-1)-xCoord][yCoord], rotation);
                    }
                }
                return rotated;
            }
            case '|' : {
                for(int xCoord = 0; xCoord < gridSize; xCoord++) {
                    for(int yCoord = 0; yCoord < gridSize; yCoord++) {
                        rotated[xCoord][yCoord] = rotateCharacter(grid[xCoord][(gridSize-1)-yCoord], rotation);
                    }
                }
                return rotated;
            }
            case '\\' : {
                Character[][] partialRotation = rotateGrid(grid, gridSize, '>');
                return rotateGrid(partialRotation, gridSize, '|');
            }
            default: {
                Character[][] partialRotation = rotateGrid(grid, gridSize, '<');
                return rotateGrid(partialRotation, gridSize, '|');
            }
        }
    }

    private static Character rotateCharacter(Character character, Character rotation) {
        if ((character.equals('x')) || character.equals('o')) {
            return character;
        } else {
            switch (character) {
                case '<': {
                    switch (rotation) {
                        case '<': {
                            return 'v';
                        }
                        case '>': {
                            return '^';
                        }
                        case '|': {
                            return '>';
                        }
                        case '-': {
                            return '<';
                        }
                        case '\\': {
                            return '^';
                        }
                        default: {
                            return 'v';
                        }
                    }
                }
                case '>': {
                    switch (rotation) {
                        case '<': {
                            return '^';
                        }
                        case '>': {
                            return 'v';
                        }
                        case '|': {
                            return '<';
                        }
                        case '-': {
                            return '>';
                        }
                        case '\\': {
                            return 'v';
                        }
                        default: {
                            return '^';
                        }
                    }
                }
                case '^': {
                    switch (rotation) {
                        case '<': {
                            return '<';
                        }
                        case '>': {
                            return '>';
                        }
                        case '|': {
                            return '^';
                        }
                        case '-': {
                            return 'v';
                        }
                        case '\\': {
                            return '<';
                        }
                        default: {
                            return '>';
                        }
                    }
                }
                case 'v': {
                    switch (rotation) {
                        case '<': {
                            return '>';
                        }
                        case '>': {
                            return '<';
                        }
                        case '|': {
                            return 'v';
                        }
                        case '-': {
                            return '^';
                        }
                        case '\\': {
                            return '>';
                        }
                        default: {
                            return '<';
                        }
                    }
                }


                case '|': {
                    switch (rotation) {
                        case '<': {
                            return '-';
                        }
                        case '>': {
                            return '-';
                        }
                        case '|': {
                            return '|';
                        }
                        case '-': {
                            return '|';
                        }
                        case '\\': {
                            return '-';
                        }
                        default: {
                            return '-';
                        }
                    }
                }
                case '-': {
                    switch (rotation) {
                        case '<': {
                            return '|';
                        }
                        case '>': {
                            return '|';
                        }
                        case '|': {
                            return '-';
                        }
                        case '-': {
                            return '-';
                        }
                        case '\\': {
                            return '|';
                        }
                        default: {
                            return '|';
                        }
                    }
                }
                case '/': {
                    switch (rotation) {
                        case '<': {
                            return '\\';
                        }
                        case '>': {
                            return '\\';
                        }
                        case '|': {
                            return '\\';
                        }
                        case '-': {
                            return '\\';
                        }
                        case '\\': {
                            return '\\';
                        }
                        default: {
                            return '/';
                        }
                    }
                }
                default: { // '\'
                    switch (rotation) {
                        case '<': {
                            return '/';
                        }
                        case '>': {
                            return '/';
                        }
                        case '|': {
                            return '/';
                        }
                        case '-': {
                            return '/';
                        }
                        case '\\': {
                            return '\\';
                        }
                        default: {
                            return '/';
                        }
                    }
                }
            }
        }
    }
}
