AtCoder Grand Contest 021 - Tiling

Takahashi has an N \times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \times 2 tiles (1 vertical, 2 horizontal) and B 2 \times 1 tiles (2 vertical, 1 horizontal) satisfying the following conditions, and construct one arrangement of the tiles if it is possible:

* All the tiles must be placed on the grid.
* Tiles must not stick out of the grid, and no two different tiles may intersect.
* Neither the grid nor the tiles may be rotated.
* Every tile completely covers exactly two squares.

Constraints

* 1 \leq N,M \leq 1000
* 0 \leq A,B \leq 500000
* N, M, A and B are integers.

Input

Input is given from Standard Input in the following format:


N M A B


Output

If it is impossible to place all the tiles, print `NO`. Otherwise, print the following:


YES
c_{11}...c_{1M}
:
c_{N1}...c_{NM}


Here, c_{ij} must be one of the following characters: `.`, `<`, `>`, `^` and `v`. Represent an arrangement by using each of these characters as follows:

* When c_{ij} is `.`, it indicates that the square at the i-th row and j-th column is empty;
* When c_{ij} is `<`, it indicates that the square at the i-th row and j-th column is covered by the left half of a 1 \times 2 tile;
* When c_{ij} is `>`, it indicates that the square at the i-th row and j-th column is covered by the right half of a 1 \times 2 tile;
* When c_{ij} is `^`, it indicates that the square at the i-th row and j-th column is covered by the top half of a 2 \times 1 tile;
* When c_{ij} is `v`, it indicates that the square at the i-th row and j-th column is covered by the bottom half of a 2 \times 1 tile.

Examples

Input

3 4 4 2


Output

YES
<><>
^<>^
v<>v


Input

4 5 5 3


Output

YES
<>..^
^.<>v
v<>.^
<><>v


Input

7 9 20 20


Output

NO

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
(N, M, A, B) = map(int, input().split())

def solve(n, m, a, b):
	if a * 2 + b * 2 > n * m:
		return False
	else:
		ans = [['.' for x in range(m)] for y in range(n)]
		remainA = a
		remainB = b
		nx = 0
		ny = 0
		gx = n
		gy = m
		if n % 2:
			nx = 1
			cnt = 0
			while True:
				if cnt > m - 2 or remainA == 0:
					break
				ans[0][cnt] = '<'
				ans[0][cnt + 1] = '>'
				remainA -= 1
				cnt += 2
		if m % 2:
			gy -= 1
			cnt = 0
			while True:
				if cnt > n - 2 or remainB == 0:
					break
				ans[cnt][m - 1] = '^'
				ans[cnt + 1][m - 1] = 'v'
				remainB -= 1
				cnt += 2
		if (n == 1 or m == 1) and (remainA > 0 or remainB > 0):
			return False
		cna = remainA
		cnb = remainB
		for i in range(cnb // 2):
			ans[nx][ny] = '^'
			ans[nx + 1][ny] = 'v'
			ans[nx][ny + 1] = '^'
			ans[nx + 1][ny + 1] = 'v'
			remainB -= 2
			if ny + 2 < gy - 1:
				ny += 2
			elif nx + 2 < gx - 1:
				nx += 2
				ny = 0
			elif remainA > 0 or remainB > 0:
				return False
			else:
				return ans
		for i in range(cna // 2):
			ans[nx][ny] = '<'
			ans[nx][ny + 1] = '>'
			ans[nx + 1][ny] = '<'
			ans[nx + 1][ny + 1] = '>'
			remainA -= 2
			if ny + 2 < gy - 1:
				ny += 2
			elif nx + 2 < gx - 1:
				nx += 2
				ny = 0
			elif remainA > 0 or remainB > 0:
				return False
			else:
				return ans
		if remainA % 2 == 0 and remainB % 2 == 0:
			return ans
		elif remainA % 2 == 1 and remainB % 2 == 1:
			ans[nx][ny] = '^'
			ans[nx + 1][ny] = 'v'
			if ny + 2 < gy - 1:
				ny += 2
			elif nx + 2 < gx - 1:
				nx += 2
				ny = 0
			else:
				if ans[n - 1][m - 1] == '.' and ans[n - 1][m - 2] == '.':
					ans[n - 1][m - 1] = '>'
					ans[n - 1][m - 2] = '<'
					return ans
				return False
			ans[nx][ny] = '<'
			ans[nx][ny + 1] = '>'
			return ans
		elif remainA % 2 == 1:
			ans[nx][ny] = '<'
			ans[nx][ny + 1] = '>'
			return ans
		else:
			ans[nx][ny] = '^'
			ans[nx + 1][ny] = 'v'
			return ans
Ans = solve(N, M, A, B)
if Ans:
	print('YES')
	for i in range(N):
		res = ''.join(Ans[i])
		print(res)
else:
	print('NO')


def get_next_int():
	return int(float(input()))

def get_next_ints(delim=' '):
	return tuple([int(float(x)) for x in input().split(delim)])

def get_next_str():
	return input()

def get_next_strs(delim=' '):
	return tuple(input().split(delim))

def get_next_by_types(*value_types, delim=' '):
	return tuple([t(x) for (t, x) in zip(value_types, input().split(delim))])

def main(print=print):
	(n, m, a, b) = get_next_ints()
	result = {}
	if n % 2 == 1:
		for j in range(1, m, 2):
			if a == 0:
				break
			result[n, j] = '<'
			result[n, j + 1] = '>'
			a -= 1
	if m % 2 == 1:
		for i in range(1, n, 2):
			if b == 0:
				break
			result[i, m] = '^'
			result[i + 1, m] = 'v'
			b -= 1
	if n % 2 == 1 and a % 2 == 1 and (m % 2 == 1) and (b % 2 == 1):
		result[n, m - 2] = '<'
		result[n, m - 1] = '>'
		result[n - 2, m - 1] = '<'
		result[n - 2, m] = '>'
		result[n - 1, m] = '^'
		result[n, m] = 'v'
		result[n - 2, m - 2] = '^'
		result[n - 1, m - 2] = 'v'
		a -= 1
		b -= 1
	inside_n = n - n % 2
	inside_m = m - m % 2
	for i in range(1, inside_n + 1, 2):
		for j in range(1, inside_m + 1, 2):
			if a > 0:
				result[i, j] = '<'
				result[i, j + 1] = '>'
				a -= 1
				if a > 0:
					result[i + 1, j] = '<'
					result[i + 1, j + 1] = '>'
					a -= 1
			elif b > 0:
				result[i, j] = '^'
				result[i + 1, j] = 'v'
				b -= 1
				if b > 0:
					result[i, j + 1] = '^'
					result[i + 1, j + 1] = 'v'
					b -= 1
			else:
				break
		if a + b == 0:
			break
	if a + b > 0:
		print('NO')
	else:
		print('YES')
		for i in range(1, n + 1):
			buffer = []
			for j in range(1, m + 1):
				buffer.append(result.get((i, j), '.'))
			print(''.join(buffer))
main()


def solve(n, m, a, b):
	cell = n * m
	need = 2 * (a + b)
	if cell < need:
		return 'NO'
	d = '.<>^v'
	f = [[0] * m for _ in range(n)]
	if n & 1:
		for j in range(0, m - 1, 2):
			if a:
				f[-1][j] = 1
				f[-1][j + 1] = 2
				a -= 1
			else:
				break
	if m & 1:
		for i in range(0, n - 1, 2):
			if b:
				f[i][-1] = 3
				f[i + 1][-1] = 4
				b -= 1
			else:
				break
	sqa = a // 2
	sqb = b // 2
	sq = sqa + sqb
	(ra, rb) = (a & 1, b & 1)
	sqc = n // 2 * (m // 2)
	if sq > sqc:
		return 'NO'
	if sq == sqc and (ra or rb):
		return 'NO'
	if sq + 1 == sqc and (ra and rb):
		if n & 1 and m & 1:
			f[-3][-3] = f[-1][-2] = 1
			f[-3][-2] = f[-1][-1] = 2
			f[-3][-1] = f[-2][-3] = 3
			f[-2][-1] = f[-1][-3] = 4
			ra = rb = 0
		else:
			return 'NO'
	(i, j) = (0, 0)
	for i in range(0, n - 1, 2):
		for j in range(0, m - 1, 2):
			if sqa:
				f[i][j] = f[i + 1][j] = 1
				f[i][j + 1] = f[i + 1][j + 1] = 2
				sqa -= 1
			elif sqb:
				f[i][j] = f[i][j + 1] = 3
				f[i + 1][j] = f[i + 1][j + 1] = 4
				sqb -= 1
			else:
				break
		else:
			continue
		break
	if ra:
		f[i][j] = 1
		f[i][j + 1] = 2
		j += 2
		if j >= m - 1:
			j = 0
			i += 2
	if rb:
		f[i][j] = 3
		f[i + 1][j] = 4
	return 'YES\n' + '\n'.join((''.join(map(d.__getitem__, r)) for r in f))
(n, m, a, b) = map(int, input().split())
print(solve(n, m, a, b))


(n, m, a, b) = map(int, input().split())
board = [['.'] * m for _ in range(n)]
if n * m < 2 * (a + b):
	print('NO')
	exit()
if n == 1 or m == 1:
	if n == 1 and m == 1:
		if a == 0 and b == 0:
			print('YES')
			print('.')
		else:
			print('NO')
			exit()
	elif n == 1:
		if b >= 1:
			print('NO')
			exit()
		elif m // 2 < a:
			print('NO')
			exit()
		else:
			for x in range(0, m // 2):
				board[0][2 * x] = '<'
				board[0][2 * x + 1] = '>'
			print('YES')
			for i in range(n):
				print(''.join(map(str, board[i])))
	elif m == 1:
		if a >= 1:
			print('NO')
			exit()
		elif n // 2 < b:
			print('NO')
			exit()
		else:
			for y in range(0, n // 2):
				board[2 * y][0] = '^'
				board[2 * y + 1][0] = 'v'
			print('YES')
			for i in range(n):
				print(''.join(map(str, board[i])))
elif n * m % 2 != 1:
	if n % 2 == 1:
		tmp = min(m // 2, a)
		a -= tmp
		for i in range(tmp):
			board[n - 1][2 * i] = '<'
			board[n - 1][2 * i + 1] = '>'
	if m % 2 == 1:
		tmp = min(n // 2, b)
		b -= tmp
		for i in range(tmp):
			board[2 * i][m - 1] = '^'
			board[2 * i + 1][m - 1] = 'v'
	for y in range(0, n - n % 2, 2):
		for x in range(0, m - m % 2, 2):
			if a >= 2:
				a -= 2
				board[y][x] = '<'
				board[y][x + 1] = '>'
				board[y + 1][x] = '<'
				board[y + 1][x + 1] = '>'
			elif a == 1:
				a -= 1
				board[y][x] = '<'
				board[y][x + 1] = '>'
			elif b >= 2:
				b -= 2
				board[y][x] = '^'
				board[y + 1][x] = 'v'
				board[y][x + 1] = '^'
				board[y + 1][x + 1] = 'v'
			elif b == 1:
				b -= 1
				board[y][x] = '^'
				board[y + 1][x] = 'v'
	if a != 0 or b != 0:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			print(''.join(map(str, board[i])))
else:
	if n % 2 == 1:
		tmp = min(m // 2 - 1, a)
		a -= tmp
		for i in range(tmp):
			board[n - 1][2 * i] = '<'
			board[n - 1][2 * i + 1] = '>'
	if m % 2 == 1:
		tmp = min(n // 2 - 1, b)
		b -= tmp
		for i in range(tmp):
			board[2 * i][m - 1] = '^'
			board[2 * i + 1][m - 1] = 'v'
	for y in range(0, n - 2, 2):
		for x in range(0, m - 2, 2):
			if y == n - 3 and x == m - 3:
				continue
			if a >= b:
				if a >= 2:
					a -= 2
					board[y][x] = '<'
					board[y][x + 1] = '>'
					board[y + 1][x] = '<'
					board[y + 1][x + 1] = '>'
				elif a == 1:
					a -= 1
					board[y][x] = '<'
					board[y][x + 1] = '>'
			elif b >= 2:
				b -= 2
				board[y][x] = '^'
				board[y + 1][x] = 'v'
				board[y][x + 1] = '^'
				board[y + 1][x + 1] = 'v'
			elif b == 1:
				b -= 1
				board[y][x] = '^'
				board[y + 1][x] = 'v'
	if a >= 4 or b >= 4 or a + b >= 5:
		print('NO')
		exit()
	x = m - 3
	y = n - 3
	if a == 2 and b == 2:
		a -= 2
		b -= 2
		board[y][x] = '<'
		board[y][x + 1] = '>'
		board[y][x + 2] = '^'
		board[y + 1][x + 2] = 'v'
		board[y + 1][x] = '^'
		board[y + 2][x] = 'v'
		board[y + 2][x + 1] = '<'
		board[y + 2][x + 2] = '>'
	else:
		if a != 0:
			a -= 1
			board[y + 2][x] = '<'
			board[y + 2][x + 1] = '>'
		if b != 0:
			b -= 1
			board[y][x + 2] = '^'
			board[y + 1][x + 2] = 'v'
		if a >= 2:
			a -= 2
			board[y][x] = '<'
			board[y][x + 1] = '>'
			board[y + 1][x] = '<'
			board[y + 1][x + 1] = '>'
		elif a == 1:
			a -= 1
			board[y][x] = '<'
			board[y][x + 1] = '>'
		elif b >= 2:
			b -= 2
			board[y][x] = '^'
			board[y + 1][x] = 'v'
			board[y][x + 1] = '^'
			board[y + 1][x + 1] = 'v'
		elif b == 1:
			b -= 1
			board[y][x] = '^'
			board[y + 1][x] = 'v'
	print('YES')
	for i in range(n):
		print(''.join(map(str, board[i])))


(R, C, A, B) = map(int, input().split())
if (A + B) * 2 > R * C:
	print('NO')
	exit()
ans = [['.' for j in range(C)] for i in range(R)]
if R % 2:
	for i in range(C // 2):
		if A == 0:
			break
		ans[-1][i * 2] = '<'
		ans[-1][i * 2 + 1] = '>'
		A -= 1
if C % 2:
	for i in range(R // 2):
		if B == 0:
			break
		ans[i * 2][-1] = '^'
		ans[i * 2 + 1][-1] = 'v'
		B -= 1
for i in range(R // 2):
	for j in range(C // 2):
		if A > 1:
			for k in range(2):
				ans[i * 2 + k][j * 2] = '<'
				ans[i * 2 + k][j * 2 + 1] = '>'
				A -= 1
		elif B > 1:
			for k in range(2):
				ans[i * 2][j * 2 + k] = '^'
				ans[i * 2 + 1][j * 2 + k] = 'v'
				B -= 1
		elif A == 1:
			ans[i * 2][j * 2] = '<'
			ans[i * 2][j * 2 + 1] = '>'
			A -= 1
		elif B == 1:
			ans[i * 2][j * 2] = '^'
			ans[i * 2 + 1][j * 2] = 'v'
			B -= 1
if R % 2 and C % 2 and B and (ans[-2][-3] == '.'):
	if ans[-1][-3] == '<':
		ans[-1][-2] = '<'
		ans[-1][-1] = '>'
	ans[-2][-3] = '^'
	ans[-1][-3] = 'v'
	B -= 1
if A > 0 or B > 0:
	print('NO')
else:
	print('YES')
	print(*[''.join(row) for row in ans], sep='\n')


import math

def prity(mat):
	for i in range(len(mat)):
		for j in range(len(mat[0])):
			print(mat[i][j], end='')
		print()

def tile_a(i, j, mat):
	assert mat[i][j] == '.' and mat[i][j + 1] == '.'
	mat[i][j] = '<'
	mat[i][j + 1] = '>'

def tile_b(i, j, mat):
	assert mat[i][j] == '.' and mat[i + 1][j] == '.'
	mat[i][j] = '^'
	mat[i + 1][j] = 'v'
(N, M, A, B) = [int(_) for _ in input().split()]
(a, b) = (A, B)
mat = [['.' for j in range(M)] for i in range(N)]
if N % 2 == 1:
	i = N - 1
	for w in range(M // 2):
		if a > 0:
			j = 2 * w + M % 2
			tile_a(i, j, mat)
			a -= 1
if M % 2 == 1:
	j = M - 1
	for h in range(N // 2):
		if b > 0:
			i = 2 * h
			tile_b(i, j, mat)
			b -= 1
height = N // 2
width = M // 2
skip_lst = []
if N % 2 == 1 and M % 2 == 1 and (a % 2 == 1) and (b % 2 == 1):
	tile_a(2 * (height - 1), 0, mat)
	tile_b(2 * (height - 1) + 1, 0, mat)
	a -= 1
	b -= 1
	skip_lst.append((2 * (height - 1), 0))
for h in range(height):
	for w in range(width):
		i = 2 * h
		j = 2 * w
		if not (i, j) in skip_lst:
			if a > 1:
				tile_a(i, j, mat)
				tile_a(i + 1, j, mat)
				a -= 2
			elif a == 1:
				tile_a(i, j, mat)
				a -= 1
			elif b > 1:
				tile_b(i, j, mat)
				tile_b(i, j + 1, mat)
				b -= 2
			elif b == 1:
				tile_b(i, j, mat)
				b -= 1
if a == 0 and b == 0:
	print('YES')
	prity(mat)
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m, a, b) = LI()
	if n * m < (a + b) * 2:
		return 'NO'
	r = [['.'] * m for _ in range(n)]
	if n % 2 == 1:
		for i in range(min(a, m // 2)):
			r[-1][i * 2] = '<'
			r[-1][i * 2 + 1] = '>'
			a -= 1
	if m % 2 == 1:
		for i in range(min(b, n // 2)):
			r[i * 2][-1] = '^'
			r[i * 2 + 1][-1] = 'v'
			b -= 1
	if a % 2 * (b % 2) * (n % 2) * (m % 2) == 1 and n > 2 and (m > 2):
		r[-1][-1] = 'v'
		r[-2][-1] = '^'
		r[-3][-1] = '>'
		r[-3][-2] = '<'
		r[-3][-3] = '^'
		r[-2][-3] = 'v'
		a -= 1
		b -= 1
	for i in range(n // 2):
		for j in range(m // 2):
			if a > 0:
				r[i * 2][j * 2] = '<'
				r[i * 2][j * 2 + 1] = '>'
				if a > 1:
					r[i * 2 + 1][j * 2] = '<'
					r[i * 2 + 1][j * 2 + 1] = '>'
				a -= 2
			elif b <= 0:
				break
			else:
				r[i * 2][j * 2] = '^'
				r[i * 2 + 1][j * 2] = 'v'
				if b > 1:
					r[i * 2][j * 2 + 1] = '^'
					r[i * 2 + 1][j * 2 + 1] = 'v'
				b -= 2
	if a > 0 or b > 0:
		return 'NO'
	return 'YES\n' + '\n'.join([''.join(c) for c in r])
print(main())


(n, m, a, b) = list(map(int, input().split()))
ban = [['.'] * m for i in range(n)]
aa = a
bb = b
if n % 2 == 1 and m % 2 == 1 and (n >= 3) and (m >= 3) and (a >= 2) and (b >= 2):
	aa -= 2
	bb -= 2
	ban[-3][-3] = '<'
	ban[-3][-2] = '>'
	ban[-3][-1] = '^'
	ban[-2][-3] = '^'
	ban[-2][-1] = 'v'
	ban[-1][-3] = 'v'
	ban[-1][-2] = '<'
	ban[-1][-1] = '>'
	for i in range(0, m - m % 2 - 2, 2):
		if aa == 0:
			break
		ban[-1][i] = '<'
		ban[-1][i + 1] = '>'
		aa -= 1
	for i in range(0, n - n % 2 - 2, 2):
		if bb == 0:
			break
		ban[i][-1] = '^'
		ban[i + 1][-1] = 'v'
		bb -= 1
	n -= 1
	m -= 1
	yo = aa // 2
	ta = bb // 2
	yoa = aa % 2
	taa = bb % 2
	if n * m // 4 - 1 < yo + ta + yoa + taa:
		n += 1
		m += 1
		ban = [['.'] * m for i in range(n)]
	else:
		tu = []
		for i in range(0, n, 2):
			for j in range(0, m, 2):
				tu.append([i, j])
		tu.pop()
		for i in range(yo + ta):
			(x, y) = tu[i]
			if i < yo:
				ban[x][y] = '<'
				ban[x + 1][y] = '<'
				ban[x][y + 1] = '>'
				ban[x + 1][y + 1] = '>'
			else:
				ban[x][y] = '^'
				ban[x + 1][y] = 'v'
				ban[x][y + 1] = '^'
				ban[x + 1][y + 1] = 'v'
		if yoa and taa:
			(x, y) = tu[yo + ta]
			ban[x][y] = '<'
			ban[x][y + 1] = '>'
			(x, y) = tu[yo + ta + 1]
			ban[x][y] = '^'
			ban[x + 1][y] = 'v'
		elif yoa:
			(x, y) = tu[yo + ta]
			ban[x][y] = '<'
			ban[x][y + 1] = '>'
		elif taa:
			(x, y) = tu[yo + ta]
			ban[x][y] = '^'
			ban[x + 1][y] = 'v'
		print('YES')
		for i in ban:
			print(''.join(i))
		exit()
if n % 2 == 1:
	for i in range(0, m - m % 2, 2):
		if a == 0:
			break
		ban[-1][i] = '<'
		ban[-1][i + 1] = '>'
		a -= 1
	n -= 1
if m % 2 == 1:
	for i in range(0, n, 2):
		if b == 0:
			break
		ban[i][-1] = '^'
		ban[i + 1][-1] = 'v'
		b -= 1
	m -= 1
if n % 2 == 0 and m % 2 == 0:
	yo = a // 2
	ta = b // 2
	yoa = a % 2
	taa = b % 2
	if n * m // 4 < yo + ta + yoa + taa:
		print('NO')
		exit()
	tu = []
	for i in range(0, n, 2):
		for j in range(0, m, 2):
			tu.append([i, j])
	for i in range(yo + ta):
		(x, y) = tu[i]
		if i < yo:
			ban[x][y] = '<'
			ban[x + 1][y] = '<'
			ban[x][y + 1] = '>'
			ban[x + 1][y + 1] = '>'
		else:
			ban[x][y] = '^'
			ban[x + 1][y] = 'v'
			ban[x][y + 1] = '^'
			ban[x + 1][y + 1] = 'v'
	if yoa and taa:
		(x, y) = tu[yo + ta]
		ban[x][y] = '<'
		ban[x][y + 1] = '>'
		(x, y) = tu[yo + ta + 1]
		ban[x][y] = '^'
		ban[x + 1][y] = 'v'
	elif yoa:
		(x, y) = tu[yo + ta]
		ban[x][y] = '<'
		ban[x][y + 1] = '>'
	elif taa:
		(x, y) = tu[yo + ta]
		ban[x][y] = '^'
		ban[x + 1][y] = 'v'
print('YES')
for i in ban:
	print(''.join(i))


(N, M, A, B) = map(int, input().split())
Grid = [['.'] * M for i in range(N)]
if M % 2:
	for i in range(N // 2):
		if B > 0:
			Grid[2 * i][M - 1] = '^'
			Grid[2 * i + 1][M - 1] = 'v'
			B -= 1
if N % 2:
	for i in range(M // 2):
		if A > 0:
			Grid[N - 1][2 * i] = '<'
			Grid[N - 1][2 * i + 1] = '>'
			A -= 1
for i in range(M // 2 * (N // 2)):
	(a, b) = (i // (M // 2), i % (M // 2))
	if A > 1:
		Grid[2 * a][2 * b] = '<'
		Grid[2 * a][2 * b + 1] = '>'
		Grid[2 * a + 1][2 * b] = '<'
		Grid[2 * a + 1][2 * b + 1] = '>'
		A -= 2
	elif B > 1:
		Grid[2 * a][2 * b] = '^'
		Grid[2 * a][2 * b + 1] = '^'
		Grid[2 * a + 1][2 * b] = 'v'
		Grid[2 * a + 1][2 * b + 1] = 'v'
		B -= 2
	elif A == 1:
		Grid[2 * a][2 * b] = '<'
		Grid[2 * a][2 * b + 1] = '>'
		A -= 1
	elif B == 1:
		Grid[2 * a][2 * b] = '^'
		Grid[2 * a + 1][2 * b] = 'v'
		B -= 1
if A == B == 0:
	print('YES')
	for i in range(N):
		print(''.join(Grid[i]))
elif B == 1 and M % 2:
	if Grid[N - 1][M - 1] == '.' and Grid[N - 1][M - 2] == '>' and (Grid[N - 2][M - 2] == '.'):
		Grid[N - 1][M - 2] = '<'
		Grid[N - 1][M - 1] = '>'
		Grid[N - 1][M - 3] = 'v'
		Grid[N - 2][M - 3] = '^'
		print('YES')
		for i in range(N):
			print(''.join(Grid[i]))
	else:
		print('NO')
else:
	print('NO')