#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> n2;
struct node{
int s,e,m,s1,m1,m2;
node *l,*r;
node(int _s, int _e):
s(_s),e(_e),m((_s+_e)/2),s1(0),m1(0),m2(0){
if (s!=e){
l = new node(s,m);
r = new node (m+1,e);
}
}
void build(){
if (s==e){
s1 = n2[s];
m1 = n2[s];
m2 = s;
return;
}
l->build();
r->build();
s1 = l->s1+r->s1;
if (l->m1>r->m1){
m2=l->m2;
m1 = l->m1;
}
else{
m2 = r->m2;
m1 = r->m1;
}
}
pair<pair<int,int> ,int> query(int x,int y){
if (x>e or y<s) return make_pair(make_pair(0LL,-1LL),0LL);
if (x<=s and y>=e) return make_pair(make_pair(m1,m2),s1);
pair<pair<int,int> ,int> a = l->query(x,y);
pair<pair<int,int> ,int> b = r->query(x,y);
pair<int,int> c;
if (a.first.first>b.first.first) c= a.first;
else c = b.first;
return make_pair(c,a.second+b.second);
}
};
signed main(){
int n,k;
vector<vector<int> > n1;
cin>>n>>k;
n1.resize(n);
n2.resize(n);
for (int i = 0;i<n;i++) cin>>n2[i];
for (int i = 0;i<k;i++){
int a,b;
cin>>a>>b;
n1[a-1].push_back(b-1);
n1[b-1].push_back(a-1);
}
node *root = new node(0,n-1);
root->build();
queue<pair<pair<int,int>,int> > q;
q.push(make_pair(make_pair(0LL,n-1),0LL));
string ans = "";
int d;
for (int i = 0;i<n;i++) ans = ans+"0";
while (!q.empty()){
int x,y,z;
x = q.front().first.first;
y = q.front().first.second;
z = q.front().second;
q.pop();
pair<pair<int,int>,int> c = root->query(x,y);
if (c.second<z)continue;
ans[c.first.second] = '1';
if (c.first.second!=x) q.push(make_pair(make_pair(x,c.first.second-1),c.first.first));
if (c.first.second !=y) q.push(make_pair(make_pair(c.first.second+1,y),c.first.first));
}
cout<<ans;
return 0;
}