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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e3) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

char ch[N][N];

void func(int n, int m, int &a, int &b)
{
	int x, y, i, j;
	x = y = 1;
	while(x <= n && y <= m)
	{
		if(x == n && y == m)
		{
			break;
		}
		else if(x == n)
		{
			for(j = y+1; j <= m; j+=2)
			{
				if(b <= 0)
					break;
				ch[n][j-1] = '<';
				ch[n][j] = '>';
				b--;
			}
		}
		else if(y == m)
		{
			for(i = x+1; i <= n; i+=2)
			{
				if(a <= 0)
					break;
				ch[i-1][y] = '^';
				ch[i][y] = 'v';
				a--;
			}
		}
		else
		{
			for(i = x+1; i <= n; i+=2)
			{
				if(a <= 0)
					break;
				ch[i-1][y] = '^';
				ch[i][y] = 'v';
				a--;
			}
			for(i = x+2; i <= n; i+=2)
			{
				if(a <= 0)
					break;
				ch[i-1][m] = '^';
				ch[i][m] = 'v';
				a--;
			}
			for(j = y+1; j <= m; j+=2)
			{
				if(b <= 0)
					break;
				ch[n][j-1] = '<';
				ch[n][j] = '>';
				b--;
			}
			for(j = y+2; j <= m; j+=2)
			{
				if(b <= 0)
					break;
				ch[x][j-1] = '<';
				ch[x][j] = '>';
				b--;
			}
		}
		x++;
		y++;
		n--;
		m--;
	}
	return;
}

void solve()
{
	int n, m, i, j, a, b;
	cin >> n >> m >> a >> b;
	if((a+b)*2 > n*m)
	{
		cout << "NO" << '\n';
		return;
	}
	fo(i,1,n+1)
		fo(j,1,m+1)
			ch[i][j] = '.';
	if((a+b)*2 == n*m-1 && n == m)
	{
		func(n,m,a,b);
	}
	else if(n&1)
	{
		for(j = 2; j <= m; j+=2)
		{
			if(a <= 0)
				break;
			ch[n][j-1] = '<';
			ch[n][j] = '>';
			a--;
		}
	}
	else if(m&1)
	{
		for(i = 2; i <= n; i+=2)
		{
			if(b <= 0)
				break;
			ch[i-1][m] = '^';
			ch[i][m] = 'v';
			b--;
		}
	}
	for(i = 2; i <= n; i += 2)
		for(j = 2; j <= m; j+=2)
		{
			if(a > 0)
			{
				if(a == 1)
				{
					ch[i-1][j-1] = '<';
					ch[i-1][j] = '>';
					a--;
				}
				else
				{
					ch[i-1][j-1] = '<';
					ch[i-1][j] = '>';
					ch[i][j-1] = '<';
					ch[i][j] = '>';
					a -= 2;
				}
			}
			else if(b > 0)
			{
				if(b == 1)
				{
					ch[i-1][j-1] = '^';
					ch[i][j-1] = 'v';
					b--;
				}
				else
				{
					ch[i-1][j-1] = '^';
					ch[i][j-1] = 'v';
					ch[i-1][j] = '^';
					ch[i][j] = 'v';
					b-=2;
				}
			}
		}
	if(a > 0 || b > 0)
	{
		cout << "NO\n";
		return;
	}
	cout << "YES\n";
	fo(i,1,n+1)
	{
		fo(j,1,m+1)
			cout << ch[i][j];
		cout << '\n';
	}
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}