Problem:
Score : 300 points

Problem Statement

We have a square grid with H rows and W columns.
Snuke wants to write 0 or 1 in each of the squares.
Here, all of the following conditions have to be satisfied:

For every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)

For every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.

Determine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.

Constraints

1 \leq H,W \leq 1000

0 \leq A

2 \times A \leq W

0 \leq B

2 \times B \leq H

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H W A B

Output

If the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.

If the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:

s_{11}s_{12}\cdots s_{1W}
s_{21}s_{22}\cdots s_{2W}
\vdots
s_{H1}s_{H2}\cdots s_{HW}

Here s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.

If multiple solutions exist, printing any of them will be accepted.

Sample Input 1

3 3 1 1

Sample Output 1

100
010
001

Every row contains two 0s and one 1, so the first condition is satisfied.
Also, every column contains two 0s and one 1, so the second condition is satisfied.

Sample Input 2

1 5 2 0

Sample Output 2

01010

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

#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
#include<stdint.h>
using namespace std;
#define ll unsigned long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
const uint64_t pow_10[20] = {
    UINT64_C(1),
    UINT64_C(10),
    UINT64_C(100),
    UINT64_C(1000),
    UINT64_C(10000),
    UINT64_C(100000),
    UINT64_C(1000000),
    UINT64_C(10000000),
    UINT64_C(100000000),
    UINT64_C(1000000000),
    UINT64_C(10000000000),
    UINT64_C(100000000000),
    UINT64_C(1000000000000),
    UINT64_C(10000000000000),
    UINT64_C(100000000000000),
    UINT64_C(1000000000000000),
    UINT64_C(10000000000000000),
    UINT64_C(100000000000000000),
    UINT64_C(1000000000000000000),
    UINT64_C(10000000000000000000)
};

int A007376(uint64_t i)
{
    uint64_t     digits = 1U;
    uint64_t     value  = 1U;
    uint64_t     limit  = 9U;
    unsigned int tens;
    
    /* The sequence starts at index 1. Shift to zero. */
    if (!i--)
        return 0;
    
    /* Find the number of digits in each number
     in the region of index i. */
    while (i/limit >= digits) {
        const uint64_t old_limit = limit;
        
        i -= digits * limit;
        
        digits++;
        value *= 10U;
        limit *= 10U;
        
        /* If limit overflows, we are in the correct, final region. */
        if (limit <= old_limit)
            break;
    }
    
    /* We know the desired digit is i'th digit
     in a string formed by concatenating the
     9*10^(digits-1) numbers starting at 10^(digits-1).
     The value of this number is pow10(digits-1) + i/digits: */
    value += i / digits;
    
#ifdef DEBUG_OUTPUT
    fprintf(stderr, "Digit %d of %" PRIu64 " ", 1 + (int)(i % digits), value);
#endif
    
    /* Move the desired digit into the ones position. */
    value /= pow_10[(digits - 1) - (i % digits)];
    
#ifdef DEBUG_OUTPUT
    fprintf(stderr, "= %d\n", (int)(value % 10U));
#endif
    
    return value % 10U;
}
int findNthDigit(ll m) {
    ll n=m; // convert int to long
    ll start=1,  len=1,  count=9;
    
    while(n>len*count){
        n=n-len*count;
        len++;
        count=count*10;
        start=start*10;
    }
    
    // identify the number
    start = start + (n-1)/len;
    
    // identify the digit
    return (to_string(start)[((n-1)%len)]-'0');
}




ll func(ll x)
{
    if(x==0)
    {
        return 0;
    }
    ll sz=1;ll num=1;
    ll sum=0;ll last=0;
    while(sz*10<=x)
    {
        ll y=sz*10-sz;
        sum+=num*((y)*(y+1)/2);
        last=last+(sz*10-sz)*num;
        sz=sz*10;
        num++;
    }
    ll occ=x-sz+1;
    sum+=(occ)*last+(occ*(occ+1)/2)*num;
    return sum;
}
int main()
{
    fastio;
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<string> g(h);
    for(int i=0;i<h-b;i++)
    {
        g[i].resize(w);
        for(int j=0;j<a;j++)
        {
            g[i][j]='0';
        }
        for(int j=a;j<w;j++)
        {
            g[i][j]='1';
        }
    }
    for(int i=h-b;i<h;i++)
    {
        g[i].resize(w);
        for(int j=0;j<a;j++)
        {
            g[i][j]='1';
        }
        for(int j=a;j<w;j++)
        {
            g[i][j]='0';
        }
    }
    for(int i=0;i<h;i++)
    {
        cout<<g[i]<<endl;
    }
}