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 C++ (GCC 9.2.1 with AC Library v1.1) (judge verdict: Accepted)

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int K = 100000;
const int mod = 1e9 + 7;
int a[3];
string s[N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    mf_graph<int> g(n * m + 2);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (s[i][j] == '#') continue;
            if ((i + j) % 2 == 0) g.add_edge(n * m, i * m + j, 1);
            if ((i + j) % 2 == 1) g.add_edge(i * m + j, n * m + 1, 1);
            if ((i + j) % 2 == 1) continue;
            for (int l = 0; l < 4; l++){
                int ni = i + dx[l];
                int nj = j + dy[l];
                if (ni >= 0 && ni < n && nj >= 0 && nj < m && s[ni][nj] == '.'){
                    g.add_edge(i * m  + j, ni * m + nj, 1);
                }
            }
        }
    }
    cout << g.flow(n * m, n * m + 1) << endl;
    auto e = g.edges();
    for (auto x: e){
        if (x.flow == 1){
            if (x.from == n * m || x.to == n * m + 1) continue;
            int i = x.from / m;
            int j = x.from % m;
            int ni = x.to / m;
            int nj = x.to % m;
            if (i == ni){
                s[i][min(j, nj)] = '>';
                s[i][max(j, nj)] = '<';
            } else{
                s[min(i, ni)][j] = 'v';
                s[max(i, ni)][j] = '^';
            }
        }
    }
    for (int i = 0; i < n; i++) cout << s[i] << endl;
}