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

#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/maxflow>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

int main() {
    int n, m, s, t, x;
    cin >> n >> m;
    s = n * m;
    t = s + 1;

    mf_graph<int> mf(t + 1);
    vector<string> str(n);
    rep(i,0,n) cin >> str[i];

    rep(i, 0, n) {
        rep(j, 0, m) {
            x = i * m + j;
            if((i + j) % 2 == 0) {
                mf.add_edge(s, x, 1);
            } else {
                mf.add_edge(x, t, 1);
            }
        }
    }

    rep(i, 0, n) {
        rep(j, 0, m) {
            x = i * m + j;
            if ((i + j) % 2 == 1 || str[i][j] == '#') continue;

            if (i > 0 && str[i-1][j] == '.') mf.add_edge(x, x - m, 1);
            if (j > 0 && str[i][j-1] == '.') mf.add_edge(x, x - 1, 1);
            if (i < n - 1 && str[i+1][j] == '.') mf.add_edge(x, x + m, 1);
            if (j < m - 1 && str[i][j+1] == '.') mf.add_edge(x, x + 1, 1);
        }
    }

    cout << mf.flow(s, t) << endl;
    auto edge = mf.edges();
    for (auto e : edge) {
        if (e.from == s || e.to == t || e.flow == 0) continue;

        int from_i = e.from / m, from_j = e.from % m;
        int to_i = e.to / m, to_j = e.to % m;

        if (from_i == to_i) {
            if (from_j > to_j) swap(from_j, to_j);
            str[from_i][from_j] = '>';
            str[to_i][to_j] = '<';
        } else {
            if (from_i > to_i) swap(from_i, to_i);
            str[from_i][from_j] = 'v';
            str[to_i][to_j] = '^';
        }
    }

    for (auto e : str) cout << e << endl;
}