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;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
template <typename T>
struct Dinic {
  const T INF;
  struct edge {
    int to;
    T cap;
    int rev;
  };

  vector<vector<edge>> g;
  vector<int> level;
  vector<int> itr;

  Dinic (int V) : INF(numeric_limits<T>::max()) {
    g.resize(V);
  }

  void add_edge(int from, int to, T cap = 1) {
    g[from].emplace_back((edge){to, cap, (int)g[to].size()});
    g[to].emplace_back((edge){from, 0, (int)g[from].size() - 1});
  }

  bool bfs(int s, int t) {
    level.assign(g.size(), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int u = que.front(); que.pop();
      for (auto &e : g[u]) {
        if (e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[u] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] != -1;
  }

  T dfs(int u, int t, T flow) {
    if (u == t) return flow;
    for (int &i = itr[u]; i < g[u].size(); i++) {
      edge &e = g[u][i];
      if (e.cap > 0 && level[u] < level[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if (d > 0) {
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  T max_flow(int s, int t) {
    T flow = 0;
    while (bfs(s, t)) {
      itr.assign(g.size(), 0);
      T f = 0;
      while ((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  Dinic<int> mf_g(n * m + 2);
  int S = n * m, T = n * m + 1;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + 1 < n && s[i][j] == '.' && s[i + 1][j] == '.') {
        if ((i + j) % 2) mf_g.add_edge(i * m + j, (i + 1) * m + j);
        else mf_g.add_edge((i + 1) * m + j, i * m + j);
      }
      if (j + 1 < m && s[i][j] == '.' && s[i][j + 1] == '.') {
        if ((i + j) % 2) mf_g.add_edge(i * m + j, i * m + j + 1);
        else mf_g.add_edge(i * m + j + 1, i * m + j);
      }

      if ((i + j) % 2) mf_g.add_edge(S, i * m + j);
      else mf_g.add_edge(i * m + j, T);
    }
  }

  cout << mf_g.max_flow(S, T) << endl;

  for (int i = 0; i < n * m; i++) {
    for (auto e : mf_g.g[i]) {
      int x1 = i / m, y1 = i % m;
      int x2 = e.to / m, y2 = e.to % m;
      if (e.to >= n * m) continue;
      if (i > e.to) swap(x1, x2), swap(y1, y2);
      if (s[x1][y1] == '.' && s[x2][y2] == '.' && e.cap == 1) {
        if (x1 == x2) s[x1][y1] = '>', s[x2][y2] = '<';
        else s[x1][y1] = 'v', s[x2][y2] = '^'; 
      }
    }
  }

  for (auto e : s) cout << e << endl;
  return 0; 
}