/*
_____________________.
|____________________| $$\ $$\ $$\ $$\
|____________________| $$ | \__| $$ | $$ |
|____________________| $$$$$$\ $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$$\ $$$$$$\ $$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$$\
|____________________| \_$$ _| $$ __$$\ \____$$\ $$ __$$\ $$ _____| $$ __$$\ $$ |$$ __$$\ $$ __$$\\_$$ _| $$ _____|
|____________________| $$ | $$ | \__|$$$$$$$ |$$ | $$ |\$$$$$$\ $$ | \__|$$ |$$ / $$ |$$ | $$ | $$ | \$$$$$$\
$$ |$$\ $$ | $$ __$$ |$$ | $$ | \____$$\ $$ | $$ |$$ | $$ |$$ | $$ | $$ |$$\ \____$$\
\$$$$ |$$ | \$$$$$$$ |$$ | $$ |$$$$$$$ | $$ | $$ |\$$$$$$$ |$$ | $$ | \$$$$ |$$$$$$$ |
へ ♡ \____/ \__| \_______|\__| \__|\_______/ \__| \__| \____$$ |\__| \__| \____/ \_______/
૮ - ՛) $$\ $$ |
/ ⁻ ៸| \$$$$$$ | are human rights :3
乀 (ˍ,ل ل \______/
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<pair<T, long long>, null_type,
less<pair<T, long long>>, rb_tree_tag,
tree_order_statistics_node_update>;
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf (ll)1e14+4
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define mp make_pair
#define pll pair<ll,ll>
#define kth_smallest find_by_order
#define num_of_smaller order_of_key
#define fori(x) for(ll i=0;i<x;i++)
#define forj(y) for(ll j=0;j<y;j++)
#define fork(z) for(ll k=0;k<z;k++)
#define forl(a) for(ll l=0;l<a;l++)
#define DEBUG
#ifdef DEBUG
#define show(x) cerr<<#x<<" is "<<x<<endl;
#define show2(x,y) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
#define show3(x,y,z) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl;
#define show4(x,y,z,a) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<" "<<#a<<" is "<<a<<endl;
#define show_vec(a) for(auto &i:a)cerr<<i<<" ";cerr<<endl;
#define skillissue cerr<<"your code is running\n";
#define getchar_unlocked _getchar_nolock // comment before submission
#else
#define show(x)
#define show2(x,y)
#define show3(x,y,z)
#define show4(x,y,z,a)
#define show_vec(a)
#define skillissue
#endif
/*
inline int readint() {
int x=0; char ch=getchar_unlocked(); bool s=1;
while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
return s?x:-x;
}
*/
const ll maxn=2e5+4;
ll par[maxn];
ll sz[maxn];
ll findpar(ll a){
if(a==par[a])return a;
return par[a]=findpar(par[a]);
}
void merge(ll a,ll b){
ll temp=sz[findpar(a)];
sz[findpar(a)]=0;
sz[findpar(b)]+=temp;
par[findpar(a)]=findpar(b);
}
vector<ll>adj[maxn];
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n,k;cin>>n>>k;
fori(maxn)par[i]=i;
ll b[n];
pll a[n];
fori(n){
cin>>a[i].fi;
a[i].se=i;
b[i]=a[i].fi;
}
fori(n)sz[i]=a[i].fi;
vector<ll> mer[maxn];
pll ed[k];
ll A[n];
fori(n)A[i]=a[i].fi;
unordered_map<ll,ll>rank;
sort(A,A+n);
fori(n){
rank[A[i]]=i;
}
vector<ll>adj[n];
fori(k){
cin>>ed[i].fi>>ed[i].se;
ed[i].fi--;ed[i].se--;
if(a[ed[i].fi].fi>a[ed[i].se].fi){
mer[rank[a[ed[i].fi].fi]].pb(i);
}else{
mer[rank[a[ed[i].se].fi]].pb(i);
}
adj[ed[i].fi].pb(ed[i].se);
adj[ed[i].se].pb(ed[i].fi);
}
ll s[n];
ll r=0;
sort(a,a+n);
fori(n){
while(r<n and r<=rank[a[i].fi]){
for(auto j:mer[r]){
merge(ed[j].fi,ed[j].se);
}
r++;
}
s[a[i].se]=sz[findpar(a[i].se)];
}
bool ans[n];fori(n)ans[i]=0;
//ll sum=0;
//fori(n)sum+=b[i];
//fori(n)show2(i,s[i]);
ans[a[n-1].se]=1;
for(ll i=n-1;i>=0;i--){
for(auto u:adj[a[i].se]){
//show2(a[i].se,u)
if(s[u]>=b[a[i].se]){
ans[u]|=ans[a[i].se];
}
}
}
fori(n)cout<<(ans[i]==1?1:0);
}