#include <vector>

using namespace std;

enum class TILE : int
{
    open, wall, blocked, goal,
    left, up, right, down,
    path_left, path_up, path_right, path_down,
};

TILE* map = nullptr;

#define int_to_tile( integer )  static_cast< TILE >( integer )
#define tile_to_int( tile )     static_cast< int >( tile )
#define tile_at( p )            map[ p.x + p.y * map_size.x ]

struct POINT
{
    int x, y;

    bool operator!=( const POINT& rhs ) const
    {
        return  x != rhs.x || y != rhs.y;
    }

    const POINT operator+( const POINT& rhs ) const
    {
        return { x + rhs.x, y + rhs.y };
    }

    POINT& move( const TILE direction )
    {
        constexpr POINT delta[ 4 ] =
        {
            { -1,  0 },
            {  0, -1 },
            {  1,  0 },
            {  0,  1 },
        };
        return *this = ( *this + delta[ tile_to_int( direction ) & 3 ] );
    }
};

POINT map_size;
POINT start, goal;

inline bool empty( const POINT point, const TILE direction )
{
    POINT p = point;
    p.move( direction );
    return  tile_at( p ) == TILE::open;
}

bool trace_map()
{
    vector< POINT > branch;

    // path finding
    POINT position = start;
    while( position != goal )
    {
        int dir = 0;
        for( int d = 0; d < 4; ++d )
            if( empty( position, int_to_tile( d ) ) )
                dir = dir * 4 + d;

        if( dir == 0 ) // blocked
        {
            if( branch.empty() )
                return  false;
            tile_at( position ) = TILE::blocked;
            position = branch.back();
            branch.pop_back();
            continue;
        }
        else if( dir >= 4 ) // many ways
        {
            branch.push_back( position );
        }
        // else : single way
        dir &= 3;
        tile_at( position ) = int_to_tile( dir + 4 );
        position.move( int_to_tile( dir ) );
    }

    // path drawing
    position = start;
    while( position != goal )
        position.move( int_to_tile( *(int*)&tile_at( position ) += 4 ) );

    tile_at( position ) = TILE::goal;
    return  true;
}

#include <iostream>

void load_map()
{
    if( map != nullptr ) delete[] map;
    map = new TILE[ map_size.x * map_size.y ];
    while( getchar() != 10 );
    for( int y = 0; y < map_size.y; ++y )
    {
        auto* scanline = map + y * map_size.x;
        for( int x = 0; x < map_size.x; ++x )
            scanline[ x ] = int_to_tile( getchar() - '0' );
        while( getchar() != 10 );
    }
}

void print_map()
{
    const char shapes[] =
    { ' ', '#', ' ', '+', ' ', ' ', ' ', ' ', '<', '^', '>', 'v' };

    for( int y = 0; y < map_size.y; ++y )
    {
        auto* scanline = map + y * map_size.y;
        for( int x = 0; x < map_size.x; ++x )
            putchar( shapes[ tile_to_int( scanline[ x ] ) ] );
        putchar( 10 );
    }
}

int main()
{
    cin >> map_size.x >> map_size.y;
    cin >> start.x >> start.y;
    cin >> goal.x >> goal.y;

    load_map();
    trace_map();
    print_map();

    return 0;
}