# frozen_string_literal: true

# MaxFlowGraph
class MaxFlow
  def initialize(n = 0)
    @n   = n
    @pos = []
    @g   = Array.new(n) { [] }
  end

  def add_edge(from, to, cap)
    edge_number = @pos.size
    @pos     << [from, @g[from].size]
    @g[from] << [to,   @g[to].size,       cap]
    @g[to]   << [from, @g[from].size - 1, 0]
    edge_number
  end

  def [](i)
    @pos[i]
  end
  alias get_edge []

  def edges
    @pos
  end

  def flow(s, t, flow_limit = 1 << 64)
    level = Array.new(@n)
    iter  = Array.new(@n)
    que   = []

    flow = 0
    while flow < flow_limit
      bfs(level, que, s, t)
      break if level[t] == -1

      iter.fill(0)

      while flow < flow_limit
        f = dfs(t, flow_limit - flow, s, level, iter)
        break if f == 0

        flow += f
      end
    end

    flow
  end

  def calc(s, ans, m)
    @g[s].each do |e|
      next if e[2] > 0

      i, j = e[0].divmod(m)
      @g[e[0]].each do |f|
        next if f[2] > 0

        x, y = f[0].divmod(m)

        if i == x
          j, y = y, j if y < j
          ans[i][j], ans[i][y] = '>', '<'
        else
          i, x = x, i if x < i
          ans[i][j], ans[x][j] = 'v', '^'
        end
        break
      end
    end
  end

  private
  def bfs(level, que, s, t)
    level.fill(-1)
    level[s] = 0
    que.clear
    que << s

    while (v = que.shift)
      @g[v].each do |e|
        next if e[2] == 0 || level[e[0]] >= 0
        level[e[0]] = level[v] + 1
        return if e[0] == t
        que << e[0]
      end
    end
  end

  def dfs(v, up, s, level, iter)
    return up if v == s

    res = 0
    level_v = level[v]

    iter[v].upto(@g[v].size - 1) do |i|
      e = @g[v][i]
      next if level_v <= level[e[0]] || @g[e[0]][e[1]][2] == 0

      d = dfs(e[0], [up - res, @g[e[0]][e[1]][2]].min, s, level, iter)
      next if d <= 0

      @g[v][i][2] += d
      @g[e[0]][e[1]][2] -= d
      res += d
      break if res == up
    end

    return res
  end
end
MaxFlowGraph = MaxFlow
MFGraph      = MaxFlow

n, m = gets.split.map(&:to_i)

l = n * m
mf = MaxFlowGraph.new(l + 2)

s = n.times.map { gets.chars } << Array.new(m + 1, '#')
move = [[1, 0], [0, 1]]

n.times do |i|
  m.times do |j|
    next if s[i][j] != '.'

    f = !(i.odd? ^ j.odd?)
    f ? mf.add_edge(l, i * m + j, 1) : mf.add_edge(i * m + j, l + 1, 1)

    move.each do |x, y|
      x = i + x
      y = j + y
      next if s[x][y] != '.'

      f ? mf.add_edge(i * m + j, x * m + y, 1) : mf.add_edge(x * m + y, i * m + j, 1)
    end
  end
end

puts mf.flow(l, l + 1)
mf.calc(l, s, m)
puts s[0..-2].map{ |e| e.join.chomp }
