#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mid (l + ((r - l) / 2))
#define F first
#define S second
int64_t n, m ;
vector<vector<int64_t>> adj(2e5 + 5), g(2e5 + 5) ;
vector<int64_t> a(2e5 + 5), par(2e5 + 5), sum(2e5 + 5) ;
vector<bool> vs(2e5 + 5), an(2e5 + 5) ;
bool cmp(int64_t x , int64_t y)
{
return a[x] < a[y] ;
}
int64_t get(int64_t nd)
{
return (nd == par[nd] ? nd : par[nd] = get(par[nd])) ;
}
void dfs(int64_t nd)
{
an[nd] = 1 ;
for(auto it : g[nd]) dfs(it) ;
}
void solve()
{
cin >> n >> m ;
for(int64_t i = 1 ; i <= n ; i++) cin >> a[i] ;
for(int64_t i = 1 ; i <= n ; i++) par[i] = i, sum[i] = a[i] ;
for(int64_t i = 1 ; i <= m ; i++)
{
int64_t x, y ;
cin >> x >> y ;
adj[x].pb(y), adj[y].pb(x) ;
}
vector<int64_t> id(n) ;
iota(id.begin() , id.end() , 1) ;
sort(id.begin() , id.end() , cmp) ;
for(auto i : id)
{
vs[i] = 1 ;
for(auto it : adj[i])
{
it = get(it) ;
if(!vs[it] || it == i) continue ;
if(sum[it] >= a[i]) g[i].pb(it) ;
sum[i] += sum[it], par[it] = i ;
}
}
dfs(id[n - 1]) ;
for(int64_t i = 1 ; i <= n ; i++) cout << an[i] ;
cout << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1 ;
//cin >> tt;
while (tt--) solve() ;
}