Problem:
Score : 100 points

Problem Statement

You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).
Some of the squares contain an object. All the remaining squares are empty.
The state of the grid is represented by strings S_1,S_2,\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..

Consider placing 1 \times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.
Tiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.

Calculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.

Constraints

1 \leq N \leq 100

1 \leq M \leq 100

S_i is a string with length M consists of # and ..

Input

Input is given from Standard Input in the following format:

N M
S_1
S_2
\vdots
S_N

Output

On the first line, print the maximum number of tiles that can be placed.

On the next N lines, print a configulation that achieves the maximum.
Precisely, output the strings t_1,t_2,\cdots,t_N constructed by the following way.

t_i is initialized to S_i.

For each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.

For each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.

See samples for further information.

You may print any configulation that maximizes the number of tiles.

Sample Input 1

3 3
#..
..#
...

Sample Output 1

3
#><
vv#
^^.

The following output is also treated as a correct answer.

3
#><
v.#
^><

Solution in Python (3.8.2) (judge verdict: Accepted)

code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp.vector cimport vector
from libcpp cimport bool
cdef extern from "<atcoder/maxflow>" namespace "atcoder":
    cdef cppclass mf_graph[Cap]:
        mf_graph(int n)
        int add_edge(int fr, int to, Cap cap)
        Cap flow(int s, int t)
        Cap flow(int s, int t, Cap flow_limit)
        vector[bool] min_cut(int s)
        cppclass edge:
            int frm "from"
            int to
            Cap cap
            Cap flow
            edge(edge &e)
        edge get_edge(int i)
        vector[edge] edges()
        void change_edge(int i, Cap new_cap, Cap new_flow)
 
cdef class MfGraph:
    cdef mf_graph[int] *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new mf_graph[int](n)
    cpdef int add_edge(self, int fr, int to, int cap):
        return self._thisptr.add_edge(fr, to, cap)
    cpdef int flow(self, int s, int t):
        return self._thisptr.flow(s, t)
    cpdef int flow_with_limit(self, int s, int t, int flow_limit):
        return self._thisptr.flow(s, t, flow_limit)
    cpdef vector[bool] min_cut(self, int s):
        return self._thisptr.min_cut(s)
 
    cpdef vector[int] get_edge(self, int i):
        cdef mf_graph[int].edge *e = new mf_graph[int].edge(self._thisptr.get_edge(i))
        cdef vector[int] *ret_e = new vector[int]()        
        ret_e.push_back(e.frm)
        ret_e.push_back(e.to)
        ret_e.push_back(e.cap)
        ret_e.push_back(e.flow)
        return ret_e[0]
 
    cpdef vector[vector[int]] edges(self):
        cdef vector[mf_graph[int].edge] es = self._thisptr.edges()
        cdef vector[vector[int]] *ret_es = new vector[vector[int]](es.size())
        for i in range(es.size()):
            ret_es.at(i).push_back(es.at(i).frm)
            ret_es.at(i).push_back(es.at(i).to)
            ret_es.at(i).push_back(es.at(i).cap)
            ret_es.at(i).push_back(es.at(i).flow)
        return ret_es[0]
    cpdef void change_edge(self, int i, int new_cap, int new_flow):
        self._thisptr.change_edge(i, new_cap, new_flow)
 
 
"""
import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
from atcoder import MfGraph
N,M = list(map(int,input().split()))
S = [input() for i in range(N)]

mg = MfGraph(N*M + 2)

s = N*M
t = N*M + 1

for i in range(N):
    for j in range(M):
        if S[i][j]=="#":
            continue
        v = i*M + j
        if (i+j)%2==0:
            mg.add_edge(s,v,1)
        else:
            mg.add_edge(v,t,1)

for i in range(N):
    for j in range(M):
        if (i+j)%2==1 or S[i][j]=="#":
            continue
        v0 = i*M + j
        if i>0:
            if S[i-1][j]==".":
                v1 = (i-1)*M + j
                mg.add_edge(v0,v1,1)
        if j>0:
            if S[i][j-1]==".":
                v1 = i*M + j-1
                mg.add_edge(v0,v1,1)
        if i<N-1:
            if S[i+1][j]==".":
                v1 = (i+1)*M + j
                mg.add_edge(v0,v1,1)
        if j<M-1:
            if S[i][j+1]==".":
                v1 = i*M + j+1
                mg.add_edge(v0,v1,1)

print(mg.flow(s, t))

edges = mg.edges()

T = [list(__) for __ in S]

for e in edges:
    if e[0]==s or e[1]==t or e[3]==0:
        continue
    i0 = e[0]//M
    j0 = e[0]%M
    i1 = e[1]//M
    j1 = e[1]%M
    if i0 == i1+1:
        T[i1][j1] = 'v'
        T[i0][j0] = '^'
    elif j0 == j1+1:
        T[i1][j1] = '>'
        T[i0][j0] = '<'
    elif i0 == i1-1:
        T[i1][j1] = '^'
        T[i0][j0] = 'v'
    else:
        T[i1][j1] = '<'
        T[i0][j0] = '>'

for __ in T:
    print("".join(__))