#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
/*
4 4
2 2 4 3
1 2
1 3
2 3
3 4
*/
const LL MAXN=2002;
vector<LL> adj[MAXN];
LL s[MAXN], ans[MAXN];
bool vis[MAXN];
signed main(){
FAST;
LL n,m; cin>>n>>m;
FR(i,1,n+1) cin>>s[i];
while(m--){
LL a,b; cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
FR(i,1,n+1){
memset(vis,0,sizeof(vis));
priority_queue<PLL, vector<PLL>, greater<PLL> > pq;
for (LL v:adj[i]) pq.push(mp(s[v],v));
LL cnt=1, cur=s[i];
vis[i]=true;
while (!pq.empty()){
PLL p=pq.top();
pq.pop();
LL sz=p.A, u=p.B;
//cout<<i<<": "<<u<<" "<<cur<<" "<<sz<<"\n";
if (cur<sz) break;
cnt++;
cur+=sz;
vis[u]=true;
for (LL v:adj[u]){
if (!vis[v]) pq.push(mp(s[v],v));
}
}
if (cnt>=n) ans[i]=1;
}
FR(i,1,n+1) cout<<ans[i];
return 0;
}