#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
constexpr int N = 2e5 + 5;
int value[N], order[N];
vector<int> graph[N];
int parent[N], ancestor[N];
vector<int> children[N];
int find_set(int u) {
if (parent[u] < 0) return u;
return parent[u] = find_set(parent[u]);
}
bool union_sets(int u, int v) {
u = find_set(u);
if (u == v) return false;
if (parent[u] > parent[v]) swap(u, v);
parent[u] += parent[v];
parent[v] = u;
return true;
}
long long sumvalue[N];
bool answer[N];
void dfs(int u, int p) {
answer[u] = answer[p] && sumvalue[u] >= value[p];
for (int v : children[u]) {
dfs(v, u);
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt", "r", stdin);
int n, m;
cin >> n >> m;
for (int u = 1; u <= n; u++) {
cin >> value[u];
}
while (m--) {
int u, v;
cin >> u >> v;
if (value[u] == value[v] ? u < v : value[u] < value[v]) swap(u, v);
graph[u].push_back(v);
}
iota(order + 1, order + n + 1, 1);
sort(order + 1, order + n + 1, [](const int u, const int v) {
return value[u] == value[v] ? u < v : value[u] < value[v];
});
for (int i = 1; i <= n; i++) {
int u = order[i];
parent[u] = -1;
sumvalue[u] = value[u];
for (int v : graph[u]) {
v = find_set(v);
if (union_sets(u, v)) {
v = ancestor[v];
sumvalue[u] += sumvalue[v];
children[u].push_back(v);
}
}
ancestor[find_set(u)] = u;
}
answer[0] = true;
value[0] = 0;
dfs(ancestor[find_set(1)], 0);
for (int u = 1; u <= n; u++) {
cout << answer[u];
}
return 0;
}