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) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct FordFulkerson {
  struct edge { ll to, cap, rev, idx; bool isrev; };
  vector<vector<edge>> adj;
  vector<ll> used;
  ll timestamp;
  FordFulkerson(ll n) : timestamp(0) { adj.resize(n); used.resize(n,-1); }
  void add_edge(ll from, ll to, ll cap, ll idx = -1) {
    adj[from].push_back({to, cap, (ll)adj[to].size(), idx, false});
    adj[to].push_back({from, 0, (ll)adj[from].size()-1, idx, true});
  }
  ll dfs(ll now, ll to, ll flow) {
    if (now==to) return flow;
    used[now] = timestamp;
    for (auto &x: adj[now]) {
      if (x.cap>0 && used[x.to]!=timestamp) {
        ll d = dfs(x.to, to, min(flow, x.cap));
        if (d>0) {
          x.cap -= d;
          adj[x.to][x.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  ll max_flow(ll from, ll to) {
    ll result = 0;
    for (ll f; (f=dfs(from,to,LLINF))>0; timestamp++) result += f;
    return result;
  }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, M; cin >> N >> M;
  string S[N]; rep(i,N) cin >> S[i];

  FordFulkerson ff(N*M+2);
  rep(i,N) rep(j,M) {
    if (S[i][j]=='.') {
      if ((i+j)%2==0) {
        ff.add_edge(0, i*M+j+1, 1);
        if (i!=N-1&&S[i+1][j]=='.') ff.add_edge(i*M+j+1, (i+1)*M+j+1, 1);
        if (j!=M-1&&S[i][j+1]=='.') ff.add_edge(i*M+j+1, i*M+(j+1)+1, 1);
        if (i!=0  &&S[i-1][j]=='.') ff.add_edge(i*M+j+1, (i-1)*M+j+1, 1);
        if (j!=0  &&S[i][j-1]=='.') ff.add_edge(i*M+j+1, i*M+(j-1)+1, 1);
      }
      else ff.add_edge(i*M+j+1, N*M+1, 1);
    }
  }

  ll sum = ff.max_flow(0,N*M+1);
  string result[N]; rep(i,N) result[i] = S[i];

  for (auto &x: ff.adj[0]) {
    if (x.cap==0) {
      ll xh = (x.to-1)/M, xw = (x.to-1)%M;
      for (auto &y: ff.adj[x.to]) {
        ll yh = (y.to-1)/M, yw = (y.to-1)%M;
        if (!y.isrev && y.cap==0) {
          if (y.to==x.to+1) {
            result[xh][xw] = '>';
            result[yh][yw] = '<';
          } 
          else if (y.to==x.to+M) {
            result[xh][xw] = 'v';
            result[yh][yw] = '^';
          }
          else if (y.to==x.to-1) {
            result[xh][xw] = '<';
            result[yh][yw] = '>';
          } 
          else if (y.to==x.to-M) {
            result[xh][xw] = '^';
            result[yh][yw] = 'v';
          }
        }
      }
    }
  }

  cout << sum << endl;
  rep(i,N) cout << result[i] << endl;

  return 0;
}