#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mid (l + ((r - l) / 2))
#define F first
#define S second
void solve()
{
int64_t n, m ;
cin >> n >> m ;
vector<int64_t> a(n + 1) ;
for(int64_t i = 1 ; i <= n ; i++) cin >> a[i] ;
vector<vector<int64_t>> adj(n + 1) ;
for(int64_t i = 1 ; i <= m ; i++)
{
int64_t x, y ;
cin >> x >> y ;
adj[x].pb(y), adj[y].pb(x) ;
}
string s = "" ;
for(int64_t i = 1 ; i <= n ; i++)
{
char c = '1' ;
priority_queue<pair<int64_t , int64_t>> pq ;
vector<bool> vs(n + 1) ;
pq.push({0 , i}), vs[i] = 1 ;
int64_t sum = a[i] ;
while(pq.size() > 0)
{
int64_t x = pq.top().F, y = pq.top().S ;
if(-x > sum) c = '0' ;
pq.pop(), sum -= x, vs[y] = 1 ;
for(auto it : adj[y]) if(!vs[it]) pq.push({-a[it] , it}) ;
}
s += c ;
}
cout << s << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1 ;
//cin >> tt;
while (tt--) solve() ;
}