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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, K; cin >> N >> K;
	set<char> D;
	for(int i = 0; i < K; i++) {
		char d; cin >> d;
		D.insert(d);
	}
	int ans = N;
	while(true) {
		string n = to_string(ans);
		bool flag = true;
		for(int i = 0; i < n.size(); i++) {
			if(D.count(n[i])) {
				flag = false;
				break;
			}
		}
		if(flag) {
			cout << ans << endl;
			return 0;
		}
		ans++;
	}
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    char s[H][W];
    rep(i, H){
        rep(j, W){
            if((i < B && j < A) || (i >= B && j >= A)) s[i][j] = '1';
            else s[i][j] = '0';
        }
    }
    rep(i, H){
        rep(j, W) cout << s[i][j]; cout << endl;
    }
}