#include <bits/stdc++.h>
using namespace std;
const int N = 220000;
unordered_map<long long, bool> H;
bool ok = true;
int qn, r[N], b[N], deg[N], a[N], vis[N];
vector<int> adj[N], radj[N], vec[N], v;
set<pair<int, int> > cand;
void dfs(int u) {
  if (!ok) return;
  if (r[u] && !(r[u] > b[u])) {
    ok = false;
    return;
  }
  a[u] = (r[u] ? r[u] : b[u] + 1);
  vis[u] = 1;
  qn++;
  for (int v : adj[u]) {
    b[v] = max(b[v], a[u]);
    if (!(--deg[v]) && !vis[v]) dfs(v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> r[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    swap(u, v);
    if (H.count(1LL * u * N + v)) continue;
    H[1LL * u * N + v] = true;
    adj[u].push_back(v);
    radj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) deg[i] = radj[i].size();
  for (int i = 1; i <= n; i++)
    if (!deg[i] && !vis[i]) dfs(i);
  for (int i = 1; i <= n; i++) b[i] = a[i];
  if (!ok || qn != n) return puts("-1"), 0;
  for (int i = 1; i <= n; i++)
    if (b[i] > k) return puts("-1"), 0;
  for (int i = 1; i <= n; i++) vec[b[i]].push_back(i);
  for (int i = 1; i <= n; i++) {
    deg[i] = adj[i].size();
    if (!deg[i] && !r[i]) cand.insert(make_pair(b[i], i));
  }
  for (int i = k; i >= 1; i--) {
    while (!cand.empty() && cand.rbegin()->first >= i)
      cand.erase(*cand.rbegin());
    v.clear();
    for (int j = 0; j < vec[i].size(); j++)
      if (b[vec[i][j]] == i) v.push_back(vec[i][j]);
    vec[i] = v;
    while (vec[i].empty()) {
      if (cand.empty()) break;
      int x = cand.rbegin()->second;
      cand.erase(*cand.rbegin());
      b[x] = i;
      vec[i].push_back(x);
    }
    if (vec[i].empty()) {
      return puts("-1"), 0;
    }
    for (int u : vec[i])
      for (int v : radj[u]) {
        deg[v]--;
        if (!deg[v] && !r[v]) cand.insert(make_pair(b[v], v));
      }
  }
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  cout << endl;
  return 0;
}
