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: Accepted)

#include <cassert>
#include <algorithm>
#include <vector>

template<typename T>
struct FlowGraph {
private:
  struct edge {
    const int from, to;
    T cap;
    const int r_idx;
    const bool is_rev;
    edge(int f, int t, T c, int i, bool is_rev) :
      from(f), to(t), cap(c), r_idx(i), is_rev(is_rev) {}
  };

  std::vector<std::vector<edge>> G;

  T dfs(int v, int sink, T min_cap, std::vector<bool>& visited){
    visited[v] = true;
    if(v == sink) return min_cap;
    for(auto& e : G[v]){
      if(e.cap == T()) continue;
      if(visited[e.to]) continue;
      T min_cap_ = std::min(min_cap,e.cap);
      T flowed = dfs(e.to,sink,min_cap_, visited);
      if(flowed == T()) continue;
      e.cap -= flowed;
      G[e.to][e.r_idx].cap += flowed;
      return flowed;
    }
    return T();
  }
  
public:
  FlowGraph(size_t n) : G(n) {}
  void add_edge(int from, int to, T cap){
    int i = G[to].size(), i_ = G[from].size();
    G[from].emplace_back(from,to,cap,i,false);
    G[to].emplace_back(to,from,T(),i_,true);//reverse edge
  }
  T max_flow(int from, int to){
    T ret = 0, INF = 1e9;
    while(true){
      std::vector<bool> visited(G.size());
      T f = dfs(from,to,INF,visited);
      if(f == T()) break;
      ret += f;
    }
    return ret;
  }
  std::vector<edge> flowed_edge(){
    std::vector<edge> ret;
    for(auto v : G){
      for(auto e : v){
        if(e.is_rev) continue;
        if(!G[e.to][e.r_idx].cap) continue;
        ret.emplace_back(e.from,e.to,G[e.to][e.r_idx].cap,e.r_idx,false);
      }
    }
    return ret;
  }
};

#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> S(N);
  for(int i = 0; i < N; ++i){
    cin >> S[i];
  }
  FlowGraph<int> G(N*M+2);
  int source = N*M, sink = source+1;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < M; ++j){
      if(S[i][j] == '#') continue;
      int v = i*M+j;
      if((i+j)%2){
        G.add_edge(source,v,1);
        if(i > 0 and S[i-1][j] != '#')
          G.add_edge(v,v-M,1);
        if(i < N-1 and S[i+1][j] != '#')
          G.add_edge(v,v+M,1);
        if(j > 0 and S[i][j-1] != '#')
          G.add_edge(v,v-1,1);
        if(j < M-1 and S[i][j+1] != '#')
          G.add_edge(v,v+1,1);
      }else{
        G.add_edge(v,sink,1);
      }
    }
  }
  cout << G.max_flow(source,sink) << '\n';
  auto flowed_edge = G.flowed_edge();
  int d[] = {M,-M,1,-1};
  string s = "v^><";
  for(auto e : flowed_edge){
    if(e.from == source) continue;
    if(e.to == sink) continue;
    for(int i = 0; i < 4; ++i){
      if(e.from+d[i] != e.to)
        continue;
      assert(S[e.from/M][e.from%M] == '.');
      assert(S[e.to/M][e.to%M] == '.');
      S[e.from/M][e.from%M] = s[i];
      S[e.to/M][e.to%M] = s[i^1];
      break;
    }
  }
  for(auto e : S)
    cout << e << '\n';
}