//Segment Tree is a State of Mind
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<" is "<<x<<endl;
#define debugp(x,y) cerr<<#x<<' '<<#y<<" is "<<x<<' '<<y<<endl;
#define debugl(x) cerr<<#x<<" is ";for(auto p:x)cerr<<p<<" ";cerr<<endl;
#define debugpl(x) cerr<<#x<<" is ";for(auto p:x)cerr<<p.first<<" "<<p.second<<" , ";cerr<<endl;
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define rdint(x,y) rnd()%(y-x+1)+x
const int inf=4e18+5;
const int mod=1e9+7;
const int mod2=998244353;
const int mod3=1e9+9;
const int maxn=2e5+5;
int n,e;
pii o[maxn];//ordering
int a[maxn];//value
bool v[maxn];
vi adj[maxn];
int p[maxn];
int bs[maxn];
int bp[maxn];
set<int> s[maxn];
int fs(int x){
if(p[x]==x)return x;
p[x]=fs(p[x]);
return p[x];
}
void ms(int x,int y,int z){
x=fs(x);
y=fs(y);
int ox=x;
if(x==y)return;
if(sz(s[x])>sz(s[y]))swap(x,y);
//y bigger
if(z){
for(auto i:s[x])s[y].insert(i);
}else{
s[y]=s[ox];
}
p[x]=y;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>e;
for(int i=1;i<=n;i++){
int x;cin>>x;
a[i]=x;
o[i]={x,i};
}
for(int i=0;i<e;i++){
int x,y;cin>>x>>y;
adj[x].pb(y);
adj[y].pb(x);
}
sort(o+1,o+n+1);
for(int i=1;i<=n;i++)p[i]=i,s[i].insert(i);
for(int ii=1;ii<=n;ii++){
int i=o[ii].se;
v[i]=1;
//set<int> c;//completed parents
int cp=a[i];
bp[i]=a[i];
//bs[i]=1;
for(int j:adj[i]){
if(!v[j]||fs(j)==i)continue;
int ss=fs(j);
cp+=bp[ss];
if(bp[ss]>=bp[i]){
//debug(bp[s]);
bs[i]+=bs[ss];
ms(i,ss,1);
}else ms(i,ss,0);
//ms(i,ss);
//p[ss]=i;
}
bp[fs(i)]=cp;
//debugp(i,bs[i])
//debugl(s[i])
//debug(i)
//debugl(s[fs(i)])
}
//debugl(s[fs(o[n].se)])
for(int i=1;i<=n;i++){
if(s[fs(o[n].se)].find(i)!=s[fs(o[n].se)].end())cout<<1;
else cout<<0;
}
cout<<'\n';
}