#include <bits/stdc++.h>

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;

const ll INF = 1e18 ;




int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N; 
    cin  >>  N;

    vector<vector<int>> A(N, vector<int>(2));

    for (int i = 0; i < N; ++i) {
        cin >> A[i][0] >> A[i][1];
    }

    auto comp = [&](vector<int>& a, vector<int>& b) {
        return a[0] + a[1] < b[0] + b[1];
    };

    sort(A.begin(), A.end(), comp);

    vector<vector<ll>> dp (N+1 , vector<ll> (N+1, INF)); 

    



    for(int i = 0 ; i <= N; ++i){

        dp[i][0] = 0 ;
    }

    for(int i = 1 ; i <= N; ++i){
        for(int j = 1 ; j <= i ; ++j ){
            dp[i][j] = dp[i-1][j]; 
            if (A[i-1][0] >= dp[i-1][j-1]){
                dp[i][j] = min(dp[i][j] , dp[i-1][j-1] + A[i-1][1]);
            }
        }
    }


    for(int j = N ;  j >= 0; --j){
        if (dp[N][j] != INF){
            cout <<  j << "\n"; 
            break; 
        }
    }

    



    
  
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vs s(b*2+1);
    rep(i, b*2+1) rep(j, a*2+1) {
        s[i].pb(((i+j)%2)+'0');
    }
    rep(i, b*2+1) for (int j=a*2+1; j<w; ++j) s[i].pb(s[i].back());
    for (int j=b*2+1; j<h; ++j) {
        s.pb(s.back());
    }
    if (w<=a*2) rep(i, h) s[i].pop_back();
    rep(i, h) cout << s[i] << endl;
    return 0;
}
