#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template<class Key, class Compare = less<Key>>
using indexed_set = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;
template<class Key, class Value, class Compare = less<Key>>
using indexed_map = tree<Key, Value, Compare, rb_tree_tag, tree_order_statistics_node_update>;
template<class Key>
using hash_set = gp_hash_table<
Key, null_type, hash<Key>, equal_to<Key>, direct_mask_range_hashing<Key>, linear_probe_fn<>,
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>>;
template<class Key, class Value>
using hash_map = gp_hash_table<
Key, Value, hash<Key>, equal_to<Key>, direct_mask_range_hashing<Key>, linear_probe_fn<>,
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// https://codeforces.com/blog/entry/79148
class Timer: chrono::high_resolution_clock {
const time_point start_time;
public:
Timer(): start_time(now()) {}
rep elapsed_time() const {
return chrono::duration_cast<chrono::milliseconds>(now() - start_time).count();
}
} timer;
// in each component, store which ones are able to merge to the entire component, as well as the sum
struct DSU {
int n;
vector<int> p, sz, loc;
vector<vector<int>> good;
vector<ll> sum;
DSU(vector<ll> v) {
n = int(v.size() - 1);
p.resize(n + 1);
iota(p.begin(), p.end(), 0);
sz.resize(n + 1, 1);
loc = p;
good.resize(n + 1);
for (int i = 1; i <= n; i++) {
good[i].push_back(i);
}
sum = v;
}
int root(int a) {
if (p[a] != a) {
p[a] = root(p[a]);
}
return p[a];
}
// t: merge a, b;
// !t: only keep b
void join(int a, int b, bool t) {
a = root(a);
b = root(b);
if (a != b) {
bool flag = 0;
if (sz[a] > sz[b]) {
swap(a, b);
flag ^= 1;
}
p[a] = b;
sz[b] += sz[a];
sum[b] += sum[a];
if (good[loc[a]].size() > good[loc[b]].size()) {
swap(loc[a], loc[b]);
flag ^= 1;
}
if (t) {
for (auto &x : good[loc[a]]) {
good[loc[b]].push_back(x);
}
}
else if (flag) {
loc[b] = loc[a];
}
}
}
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<ll> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<vector<int>> graph(n + 1);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
graph[u].push_back(v);
graph[v].push_back(u);
}
DSU dsu(a);
vector<int> order(n);
iota(order.begin(), order.end(), 1);
sort(order.begin(), order.end(), [&] (int x, int y) {
return a[x] < a[y];
});
vector<bool> vis(n + 1, 0);
for (auto &u : order) {
vis[u] = 1;
for (auto &v : graph[u]) {
if (vis[v] && dsu.root(u) != dsu.root(v)) {
dsu.join(v, u, dsu.sum[dsu.root(v)] >= a[u]);
}
}
}
string ans(n, '0');
for (auto &x : dsu.good[dsu.loc[dsu.root(1)]]) {
ans[x - 1] = '1';
}
cout << ans;
return 0;
}