Problem:
Score : 900 points

Problem Statement

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.

Sample Input 1

3 4 4 2

Sample Output 1

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

This is one example of a way to place four 1 \times 2 tiles and three 2 \times 1 tiles on a 3 \times 4 grid.

Sample Input 2

4 5 5 3

Sample Output 2

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

Sample Input 3

7 9 20 20

Sample Output 3

NO

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	ll N, M, A, B; cin >> N >> M >> A >> B;

	VS C(N);
	REP(i, N) REP(j, M) C[i].push_back('.');

	if (N == 1 && M == 1) {
	}

	else if (N == 1 && M != 1) {
		for (int j = 1; j < M && A > 0; j += 2, A--) {
			C[0][j - 1] = '<';
			C[0][j] = '>';
		}
	}

	else if (N != 1 && M == 1) {
		for (int i = 1; i < N && B > 0; i += 2, B--) {
			C[i - 1][0] = '^';
			C[i][0] = 'v';
		}
	}

	else if (N % 2 == 0 && M % 2 == 0) {
		int i = 0, j = 0;

		for (; i < N - 1 && A > 0;) {
			for (; A > 0; j += 2) {
				if (A > 0) {
					C[i][j%M] = '<';
					C[i][(j + 1) % M] = '>';
					A--;
				}
				if (A > 0) {
					C[i + 1][j%M] = '<';
					C[i + 1][(j + 1) % M] = '>';
					A--;
				}
				if (j%M == M - 2) {
					j += 2;
					i += 2;
					break;
				}
			}
		}

		for (; i < N - 1 && B > 0;) {
			for (; B > 0; j += 2) {
				if (B > 0) {
					C[i][j%M] = '^';
					C[i + 1][j%M] = 'v';
					B--;
				}
				if (B > 0) {
					C[i][(j + 1) % M] = '^';
					C[i + 1][(j + 1) % M] = 'v';
					B--;
				}
				if (j%M == M - 2) {
					j += 2;
					i += 2;
					break;
				}
			}
		}
	}
	else if (N % 2 == 0 && M % 2 != 0) {

		for (int i = 1; i < N && B > 0; i += 2, B--) {
			C[i - 1][M - 1] = '^';
			C[i][M - 1] = 'v';
		}

		int i = 0, j = 0;
		for (; i < N - 1 && A > 0;) {
			for (; A > 0; j += 2) {
				if (A > 0) {
					C[i][j % (M - 1)] = '<';
					C[i][(j + 1) % (M - 1)] = '>';
					A--;
				}
				if (A > 0) {
					C[i + 1][j % (M - 1)] = '<';
					C[i + 1][(j + 1) % (M - 1)] = '>';
					A--;
				}
				if (j % (M - 1) == M - 3) {
					j += 2;
					i += 2;
					break;
				}
			}
		}

		for (; i < N - 1 && B > 0;) {
			for (; B > 0; j += 2) {
				if (B > 0) {
					C[i][j % (M - 1)] = '^';
					C[i + 1][j % (M - 1)] = 'v';
					B--;
				}
				if (B > 0) {
					C[i][(j + 1) % (M - 1)] = '^';
					C[i + 1][(j + 1) % (M - 1)] = 'v';
					B--;
				}
				if (j % (M - 1) == M - 3) {
					j += 2;
					i += 2;
					break;
				}
			}
		}
	}
	else if (N % 2 != 0 && M % 2 == 0) {
		for (int j = 1; j < M && A > 0; j += 2, A--) {
			C[N - 1][j - 1] = '<';
			C[N - 1][j] = '>';
		}

		int i = 0, j = 0;
		for (; i < N - 2 && A > 0;) {
			for (; A > 0; j += 2) {
				if (A > 0) {
					C[i][j % M] = '<';
					C[i][(j + 1) % M] = '>';
					A--;
				}
				if (A > 0) {
					C[i + 1][j % M] = '<';
					C[i + 1][(j + 1) % M] = '>';
					A--;
				}
				if (j % M == M - 2) {
					j += 2;
					i += 2;
					break;
				}
			}
		}

		for (; i < N - 2 && B > 0;) {
			for (; B > 0; j += 2) {
				if (B > 0) {
					C[i][j % M] = '^';
					C[i + 1][j % M] = 'v';
					B--;
				}
				if (B > 0) {
					C[i][(j + 1) % M] = '^';
					C[i + 1][(j + 1) % M] = 'v';
					B--;
				}
				if (j % M == M - 2) {
					j += 2;
					i += 2;
					break;
				}
			}
		}
	}
	else if (N % 2 != 0 && M % 2 != 0) {

		for (int i = 1; i < N - 3 && B > 0; i += 2, B--) {
			C[i - 1][M - 1] = '^';
			C[i][M - 1] = 'v';
		}
		for (int j = 1; j < M - 3 && A > 0; j += 2, A--) {
			C[N - 1][j - 1] = '<';
			C[N - 1][j] = '>';
		}
		
		int i = 0, j = 0;
		for (; i < N - 2 && A > 2;) {
			if (i == N - 3 && j % (M - 1) == M - 3) break;
			for (; A > 2; j += 2) {
				if (i == N - 3 && j % (M - 1) == M - 3) break;
				if (A > 0) {
					C[i][j % (M - 1)] = '<';
					C[i][(j + 1) % (M - 1)] = '>';
					A--;
				}
				if (A > 0) {
					C[i + 1][j % (M - 1)] = '<';
					C[i + 1][(j + 1) % (M - 1)] = '>';
					A--;
				}
				if (j % (M - 1) == M - 3) {
					j += 2;
					i += 2;
					break;
				}
			}
		}

		for (; i < N - 2 && B > 2;) {
			if (i == N - 3 && j % (M - 1) == M - 3) break;
			for (; B > 2; j += 2) {
				if (i == N - 3 && j % (M - 1) == M - 3) break;
				if (B > 0) {
					C[i][j % (M - 1)] = '^';
					C[i + 1][j % (M - 1)] = 'v';
					B--;
				}
				if (B > 0) {
					C[i][(j + 1) % (M - 1)] = '^';
					C[i + 1][(j + 1) % (M - 1)] = 'v';
					B--;
				}
				if (j % (M - 1) == M - 3) {
					j += 2;
					i += 2;
					break;
				}
			}
		}

		if (A == B) {
			if (A > 0) {
				C[N - 3][M - 3] = '<';
				C[N - 3][M - 2] = '>';
				A--;
			}
			if (A > 0) {
				C[N - 1][M - 2] = '<';
				C[N - 1][M - 1] = '>';
				A--;
			}
			if (B > 0) {
				C[N - 2][M - 3] = '^';
				C[N - 1][M - 3] = 'v';
				B--;
			}
			if (B > 0) {
				C[N - 3][M - 1] = '^';
				C[N - 2][M - 1] = 'v';
				B--;
			}
		}
		else if (A > B) {
			if (A > 0) {
				C[N - 3][M - 3] = '<';
				C[N - 3][M - 2] = '>';
				A--;
			}
			if (A > 0) {
				C[N - 2][M - 3] = '<';
				C[N - 2][M - 2] = '>';
				A--;
			}
			if (A > 0) {
				C[N - 1][M - 3] = '<';
				C[N - 1][M - 2] = '>';
				A--;
			}
			if (B > 0) {
				C[N - 3][M - 1] = '^';
				C[N - 2][M - 1] = 'v';
				B--;
			}
		}
		else if (A < B) {
			if (A > 0) {
				C[N - 1][M - 3] = '<';
				C[N - 1][M - 2] = '>';
				A--;
			}
			if (B > 0) {
				C[N - 3][M - 3] = '^';
				C[N - 2][M - 3] = 'v';
				B--;
			}
			if (B > 0) {
				C[N - 3][M - 2] = '^';
				C[N - 2][M - 2] = 'v';
				B--;
			}
			if (B > 0) {
				C[N - 3][M - 1] = '^';
				C[N - 2][M - 1] = 'v';
				B--;
			}
		}
	}
	bool flg = A == 0 && B == 0;
	YN(flg);
	REP(i, N) cout << C[i] << endl;
	//if (flg) REP(i, N) cout << C[i] << endl;
	cin >> N;

	return 0;
}