// Starcraft 2 enjoyer //
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
using namespace std;
#define LSOne(X) ((X) & -(X))
const int N = 2e5 + 5;
const int M = 2e6 + 5;
const long long K = (1LL << 60) - 1;
const int LG = 20;
const long long INF = 1e18 + 5;
const int C = 26;
const int B = 1000;
const int MOD = 1e9 + 9;
int n, m, parent[N], s[N];
bool vis[N];
vector<int> adj[N];
inline void solve()
{
cin >> n >> m;
for (int x = 1; x <= n; x++)
{
int i;
cin >> i;
s[x] = i;
}
for (int x = 0; x < m; x++)
{
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int x = 1; x <= n; x++)
{
for (int y = 1; y <= n; y++)
{
vis[y] = 0;
}
long long sum = s[x];
bool b = 1;
priority_queue<pair<int, int>> pq;
pq.push({-s[x], x});
while (!pq.empty())
{
auto[w, i] = pq.top();
pq.pop();
if (vis[i])
continue;
vis[i] = 1;
// cout << i << " " << sum << " " << x << "\n";
if (s[i] > sum)
{
// cout << "BRUH\n";
b = 0;
break;
}
if (i != x)
sum += s[i];
for (int j : adj[i])
{
if (vis[j])
continue;
// cout << j << " " << s[j] << "\n";
pq.push({-s[j], j});
}
}
cout << b;
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
for (int x = 1; x <= t; x++)
{
solve();
}
return 0;
}