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 Rust (1.42.0) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::{fastout, input, marker::Bytes};
use ralgo::flow::dinic::Dinic;
use ralgo::util::modint::Integer;
use std::time::SystemTime;
use proconio::source::auto::AutoSource;

#[fastout]
fn main() {
    let begining = SystemTime::now();
    let start = SystemTime::now();
    // let source = AutoSource::from(include_str!("../../../../input"));
    input! {
    //        from source,
        h: usize,
        w: usize,
        mut b: [Bytes; h]
    }

    eprintln!("Read input {:?}", start.elapsed().unwrap()); let start = SystemTime::now();
    let mut dinic = Dinic::new();
    let enc = |u, v| u * w + v;
    let s = h * w;
    let t = s + 1;
    for u in 0..h {
        for v in 0..w {
            if b[u][v] == b'#' {
                continue;
            }
            if (u + v).is_even() {
                dinic.add_edge(s, enc(u, v), 1);
            } else {
                dinic.add_edge(enc(u, v), t, 1);
            }
        }
    }
    eprintln!("Construct first half of the graph {:?}", start.elapsed().unwrap()); let start = SystemTime::now();

    let mut edges = vec![vec![[Option::None; 4]; w]; h];

    for u in 0..h {
        for v in 0..w {
            if (u + v).is_odd() || b[u][v] == b'#' {
                continue;
            }
            if u > 0 && b[u - 1][v] == b'.' {
                edges[u][v][0] = Some(dinic.add_edge(enc(u, v), enc(u - 1, v), 1));
            }
            if u + 1 < h && b[u + 1][v] == b'.' {
                edges[u][v][1] = Some(dinic.add_edge(enc(u, v), enc(u + 1, v), 1));
            }
            if v > 0 && b[u][v - 1] == b'.' {
                edges[u][v][2] = Some(dinic.add_edge(enc(u, v), enc(u, v - 1), 1));
            }
            if v + 1 < w && b[u][v + 1] == b'.' {
                edges[u][v][3] = Some(dinic.add_edge(enc(u, v), enc(u, v + 1), 1));
            }
        }
    }
    eprintln!("Construct the second half ot the graph {:?}", start.elapsed().unwrap()); let start = SystemTime::now();
    println!("{}", dinic.max_flow(s, t).0);
    eprintln!("Solve {:?}", start.elapsed().unwrap()); let start = SystemTime::now();
    for u in 0..h {
        for v in 0..w {
            if Some(true) == edges[u][v][0].map(|e| dinic.get_flow(&e) != 0) {
                b[u][v] = b'^';
                b[u - 1][v] = b'v';
            }
            if Some(true) == edges[u][v][1].map(|e| dinic.get_flow(&e) != 0) {
                b[u][v] = b'v';
                b[u + 1][v] = b'^';
            }
            if Some(true) == edges[u][v][2].map(|e| dinic.get_flow(&e) != 0) {
                b[u][v] = b'<';
                b[u][v - 1] = b'>';
            }
            if Some(true) == edges[u][v][3].map(|e| dinic.get_flow(&e) != 0) {
                b[u][v] = b'>';
                b[u][v + 1] = b'<';
            }
        }
    }
    eprintln!("Read result {:?}", start.elapsed().unwrap()); let start = SystemTime::now();
    for line in b {
        println!("{}", String::from_utf8(line).unwrap());
    }
    eprintln!("Output {:?}", start.elapsed().unwrap());
    eprintln!("Total {:?}", begining.elapsed().unwrap());
}
*/

fn main() {
    let exe = "/tmp/bin8D51887A";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";