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 (Clang 3.8.0) (judge verdict: Runtime Error)

#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int n, m, a, b;

void output(vector2<char>& ans){
    cout << "YES" << endl;
    rep(i, n){
        rep(j, m){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> a >> b;

    if(n == 1 && m == 1){
        if(a > 0 || b > 0){
            cout << "NO" << endl;
        }else{
            cout << "YES" << endl;
            cout << '.' << endl;
        }
        return 0;
    }

    auto ans = initVec2<char>(n, m, '.');
    if(m % 2){
        for(int i = 0; i + 1 <= n - 1 && b > 0; i += 2){
            if(n % 2 && i == n - 3){
                continue;
            }
            ans[i][m-1] = '^';
            ans[i+1][m-1] = 'v';
            b--;
        }
    }
    if(n % 2){
        for(int i = 0; i + 1 <= m - 1 && a > 0; i += 2){
            if(m % 2 && i == m - 3){
                continue;
            }
            ans[n-1][i] = '<';
            ans[n-1][i+1] = '>';
            a--;
        }
    }

    for(int x = 0; x + 1 < n; x += 2){
        for(int y = 0; y + 1 < m; y += 2){
            if(n % 2 && m % 2 && x == n - 3 && y == m - 3){
                break;
            }
            if(a == 0 && b == 0){
                break;
            }
            if(a > 1){
                ans[x][y] = '<';
                ans[x][y+1] = '>';
                ans[x+1][y] = '<';
                ans[x+1][y+1] = '>';
                a -= 2;
                continue;
            }
            if(b > 1){
                ans[x][y] = '^';
                ans[x+1][y] = 'v';
                ans[x][y+1] = '^';
                ans[x+1][y+1] = 'v';
                b -= 2;
                continue;
            }
            if(a == 1){
                ans[x][y] = '<';
                ans[x][y+1] = '>';
                a -= 1;
                continue;
            }
            if(b == 1){
                ans[x][y] = '^';
                ans[x+1][y] = 'v';
                b -= 1;
                continue;
            }
        }
    }

    if(n % 2 && m % 2){
        if(a > 2 || b > 2){
            cout << "NO" << endl;
            return 0;
        }
        if(a > 1){
            ans[n-3][m-3] = '<';
            ans[n-3][m-2] = '>';
        }
        if(b > 1){
            ans[n-3][m-1] = '^';
            ans[n-2][m-1] = 'v';
        }
        if(a > 0){
            ans[n-1][m-2] = '<';
            ans[n-1][m-1] = '>';
        }
        if(b > 0){
            ans[n-2][m-3] = '^';
            ans[n-1][m-3] = 'v';
        }
        output(ans);
        return 0;
    }

    if(a > 0 || b > 0){
        cout << "NO" << endl;
        return 0;
    }
    output(ans);

    return 0;
}