#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <map>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#define SZ(x) int(x.size())
#define FR(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,n) FR(i,0,n)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define A first
#define B second
#define mp(a,b) make_pair(a,b)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef unsigned __int128 U128;
typedef __int128 I128;
typedef std::pair<int,int> PII;
typedef std::pair<LL,LL> PLL;
using namespace std;
//1st subtask: run for every village, store pq of next village with smallest size +id
//2nd subtask: ts a tree. all kids can be absorbed. i can win iff sz[i]>=s[par[i]] && par[i] can win
//3rd subtask: line. for each i, find leftmost greater and rightmost greater, then merge everything in range? u do this since while(works) s[i] doubles so log1e9
//4th subtask: not a lot of distinct s[i]
//process in increasing s[i]?
//each i: merge with kids smaller than it, and note for kid whether it can win over parent
//does ts work
const LL MAXN=2e5+5;
LL s[MAXN];
vector<LL> adj[MAXN];
LL ans[MAXN];
struct dsu{
vector<LL> p,sz;
vector<vector<LL> > c;
dsu(LL n){
p.resize(n);
sz.resize(n);
c.resize(n);
FOR(i,n){
p[i]=i;
sz[i]=s[i];
c[i].push_back(i);
}
}
LL f(LL x){
if (x==p[x]) return x;
return p[x]=f(p[x]);
}
void un(LL a, LL b, LL x){
a=f(a), b=f(b);
if (a==b) return;
if (sz[a]<sz[b]) swap(a,b);
if (sz[b]<x){
for (LL i:c[b]) ans[i]=0;
}
sz[a]+=sz[b];
if (SZ(c[b])>SZ(c[a])) swap(c[a],c[b]);
for (LL i:c[b]) c[a].push_back(i);
p[b]=a;
}
};
bool cmp(LL a, LL b){
return s[a]<s[b];
}
signed main(){
FAST;
LL n,m; cin>>n>>m;
FOR(i,n) cin>>s[i];
while(m--){
LL a,b; cin>>a>>b;
a--; b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
dsu d(n);
vector<LL> x(n);
FOR(i,n) x[i]=i;
sort(x.begin(),x.end(),cmp);
FOR(i,n) ans[i]=1;
FOR(i,n){
LL u=x[i];
for (LL v:adj[u]){
if (s[v]>s[u]) continue;
d.un(u,v,s[u]);
}
}
FOR(i,n) cout<<ans[i];
return 0;
}