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)

//wls niubi!
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const LL mod = 1e9 + 7;
inline int read()
{
	int x = 0,f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
	for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
	return x * f;
}
int n,m,a,b;
int aaamega;
const char megaplus[3][3] = 
{
	{'<','>','^'},
	{'^','.','v'},
	{'v','<','>'}
};
const char megaplusa[3][3] = 
{
	{'.','^','^'},
	{'^','v','v'},
	{'v','<','>'}
};
const char megaplusb[3][3] = 
{
	{'<','>','^'},
	{'<','>','v'},
	{'.','<','>'}
};
char grid[1010][1010];
void putgrid(int dx,int dy,int type) //2 * 2 lefttop (dx,dy)
{
    if(type == 0) // heng zhe bai
    {
        grid[dx][dy] = '<',grid[dx + 1][dy] = '<';
        grid[dx][dy + 1] = '>',grid[dx + 1][dy + 1] = '>';
	}
	else
	{
	    grid[dx][dy] = '^',grid[dx + 1][dy] = 'v';
        grid[dx][dy + 1] = '^',grid[dx + 1][dy + 1] = 'v';
	}
}
void puthalf(int dx,int dy,int type)
{
    if(type == 0) // heng zhe bai
    {
        grid[dx][dy] = '<',grid[dx][dy + 1] = '>';
	}
	else
	{
	    grid[dx][dy] = '^',grid[dx + 1][dy] = 'v';
	}
}
void fillgrid(int n,int m) //assert that n and m are even
{
	int tl = n / 2,tr = m / 2;
	int rr = tl * tr * 2;
	if(rr < a + b){puts("NO");exit(0);}
	else
	{
		for(int i=1;i+1<=n;i+=2)
			for(int j=1;j+1<=m;j+=2)
			{
				if(a > 1){putgrid(i,j,0);a -= 2;continue;}
				else if(b > 1){putgrid(i,j,1);b -= 2;continue;}
				if(a == 1)
				{
					puthalf(i,j,0);
					a--;
					continue;
				}
				else if(b == 1)
				{
				    puthalf(i,j,1);
				    b--;
				    continue;
				}
			}
		if(aaamega && (a + b == 4))
		{
			n++,m++;
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++)
				{
					if(grid[n - 2 + i][m - 2 + j] == '<')a++;if(grid[n - 2 + i][m - 2 + j] == '^')b++; 
				}
 		    if((a + b > 4) || (a == 4) || (b == 4)){puts("NO");exit(0);}
		    else
		    {
		    	puts("YES");
		    	if(a == 2 && b == 2)
		    	{
			    	for(int i=0;i<3;i++)
			    	    for(int j=0;j<3;j++)
			    	    	grid[n - 2 + i][m - 2 + j] = megaplus[i][j];
			    	for(int i=1;i<=n;i++)
					{
						for(int j=1;j<=m;j++)putchar(grid[i][j]);
						puts("");
					}
					exit(0);
				}
				else if(a == 3 && b == 1)
				{
				    for(int i=0;i<3;i++)
			    	    for(int j=0;j<3;j++)
			    	    	grid[n - 2 + i][m - 2 + j] = megaplusa[i][j];
			    	for(int i=1;i<=n;i++)
					{
						for(int j=1;j<=m;j++)putchar(grid[i][j]);
						puts("");
					}
					exit(0);
				}
				else if(a == 1 && b == 3)
				{
				    for(int i=0;i<3;i++)
			    	    for(int j=0;j<3;j++)
			    	    	grid[n - 2 + i][m - 2 + j] = megaplusb[i][j];
			    	for(int i=1;i<=n;i++)
					{
						for(int j=1;j<=m;j++)putchar(grid[i][j]);
						puts("");
					}
					exit(0);
				}
			}
		}
		else
		{
			if(a || b){puts("NO");exit(0);}
			puts("YES");
		}
	}
}
void filldown()
{
	for(int i=1;i+1<=m;i+=2)
	    if(a){puthalf(n,i,0);a--;}
}
void fillright()
{
    for(int i=1;i+1<=n;i+=2)
    	if(b){puthalf(i,m,1);b--;}
}
int main()
{
	n = read(),m = read(),a = read(),b = read();
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)grid[i][j] = '.';
	if(n & 1)
	{
		if(m & 1)
		{
			aaamega = 1;
			filldown();fillright();
		    fillgrid(n - 1,m - 1);
		}
		else
		{
			filldown();
		    fillgrid(n - 1,m);
		}
	}
	else 
	{
	    if(m & 1)
	    {
	    	fillright();
	    	fillgrid(n,m - 1);
		}
		else fillgrid(n,m);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)putchar(grid[i][j]);
		puts("");
	}
}