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 ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl '\n'
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#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 pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#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()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

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 = 50;

char ch[N][N], temp[N][N];

bool check(int i, int j, int n, int m)
{
	if(i+1 > n || j+1 > m)
		return 0;
	if(ch[i][j] == '.' && ch[i+1][j] == '.' && ch[i][j+1] == '.' && ch[i+1][j+1] == '.')
		return 1;
	return 0;
}

void print_ch(int n, int m)
{
	int i, j;
	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 n, m, a, b, i, j, tempa, tempb;
	cin >> n >> m >> a >> b;
	if((a+b)<<1 > n*m)
	{
		cout << "NO";
		return 0;
	}
	fo(i,1,n+1)
		fo(j,1,m+1)
			ch[i][j] = '.';
	if(n&1)
	{
		for(j = 1; j <= m; j += 2)
		{
			if(a <= 0)
				break;
			if(j+1 <= m && ch[n][j] == '.' && ch[n][j+1] == '.')
			{
				ch[n][j] = '<';
				ch[n][j+1] = '>';
				a--;
			}
		}
	}
	if(m&1)
	{
		for(i = 1; i <= n; i += 2)
		{
			if(b <= 0)
				break;
			if(i+1 <= n && ch[i][m] == '.' && ch[i+1][m] == '.')
			{
				ch[i][m] = '^';
				ch[i+1][m] = 'v';
				b--;
			}
		}
	}
	for(i = 1; i <= n; i += 2)
		for(j = 1; j <= m; j += 2)
		{
			if(a < 2)
				break;
			if(check(i,j,n,m))
			{
				ch[i][j] = '<';
				ch[i+1][j] = '<';
				ch[i][j+1] = '>';
				ch[i+1][j+1] = '>';
				a -= 2;
			}
		}
	for(i = 1; i <= n; i += 2)
		for(j = 1; j <= m; j += 2)
		{
			if(b < 2)
				break;
			if(check(i,j,n,m))
			{
				ch[i][j] = '^';
				ch[i+1][j] = 'v';
				ch[i][j+1] = '^';
				ch[i+1][j+1] = 'v';
				b -= 2;
			}
		}
	if(a == 1 && b == 1)
	{
		fo(i,1,n+1)
			fo(j,1,m+1)
				temp[i][j] = ch[i][j];
		tempa = a;
		tempb = b;
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(a <= 0)
					break;
				if(j+1 <= m && ch[i][j] == '.' && ch[i][j+1] == '.')
				{
					ch[i][j] = '<';
					ch[i][j+1] = '>';
					a--;
				}
			}
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(b <= 0)
					break;
				if(i+1 <= n && ch[i][j] == '.' && ch[i+1][j] == '.')
				{
					ch[i][j] = '^';
					ch[i+1][j] = 'v';
					b--;
				}
			}
		if(a == 0 && b == 0)
		{
			cout << "YES\n";
			fo(i,1,n+1)
			{
				fo(j,1,m+1)
					cout << ch[i][j];
				cout << '\n';
			}
			return 0;
		}
		fo(i,1,n+1)
			fo(j,1,m+1)
				ch[i][j] = temp[i][j];
		a = tempa;
		b = tempb;
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(b <= 0)
					break;
				if(i+1 <= n && ch[i][j] == '.' && ch[i+1][j] == '.')
				{
					ch[i][j] = '^';
					ch[i+1][j] = 'v';
					b--;
				}
			}
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(a <= 0)
					break;
				if(j+1 <= m && ch[i][j] == '.' && ch[i][j+1] == '.')
				{
					ch[i][j] = '<';
					ch[i][j+1] = '>';
					a--;
				}
			}
	}
	else if(a == 1)
	{
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(a <= 0)
					break;
				if(j+1 <= m && ch[i][j] == '.' && ch[i][j+1] == '.')
				{
					ch[i][j] = '<';
					ch[i][j+1] = '>';
					a--;
				}
			}
	}
	else if(b == 1)
	{
		fo(i,1,n+1)
			fo(j,1,m+1)
			{
				if(b <= 0)
					break;
				if(i+1 <= n && ch[i][j] == '.' && ch[i+1][j] == '.')
				{
					ch[i][j] = '^';
					ch[i+1][j] = 'v';
					b--;
				}
			}
	}
	if(a > 0 || b > 0)
	{
		cout << "NO";
		return 0;
	}
	cout << "YES\n";
	fo(i,1,n+1)
	{
		fo(j,1,m+1)
			cout << ch[i][j];
		cout << '\n';
	}
	// Code ends here

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