#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int n, m, k;
int ans[MAXN], top[MAXN], bot[MAXN], a[MAXN];
int in[MAXN], ot[MAXN];
vector<int> vec[MAXN], vin[MAXN], vot[MAXN];
queue<int> q;
struct Tpeo {
  int tp, id;
  Tpeo() {}
  Tpeo(int tpp, int idd) {
    tp = tpp;
    id = idd;
  }
  friend bool operator<(Tpeo A, Tpeo B) { return A.tp > B.tp; }
};
priority_queue<Tpeo> mi;
void solve_bot(int u, int now) {
  ans[u] = now;
  for (int i = 0; i < vin[u].size(); ++i) {
    int v = vin[u][i];
    bot[v] = max(bot[v], ans[u] + 1);
    --in[v];
    if (!in[v]) vec[bot[v]].push_back(v);
  }
}
void init() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i])
      top[i] = a[i], bot[i] = a[i];
    else
      top[i] = k, bot[i] = 1;
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ot[v]++;
    vot[u].push_back(v);
    in[u]++;
    vin[v].push_back(u);
  }
}
void solve_top() {
  for (int i = 1; i <= n; ++i)
    if (!ot[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < vot[u].size(); ++i) {
      int v = vot[u][i];
      ot[v]--;
      top[v] = min(top[v], top[u] - 1);
      if (!ot[v]) q.push(v);
    }
  }
}
void solve() {
  solve_top();
  for (int i = 1; i <= n; ++i)
    if ((a[i] && top[i] < a[i]) || top[i] < 1) {
      printf("-1\n");
      return;
    }
  for (int i = 1; i <= n; ++i)
    if (!in[i]) vec[bot[i]].push_back(i);
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < vec[i].size(); ++j) {
      int x = vec[i][j];
      mi.push(Tpeo(top[x], x));
    }
    if (mi.empty()) {
      printf("-1\n");
      return;
    }
    solve_bot(mi.top().id, i);
    mi.pop();
    while (!mi.empty() && mi.top().tp == i) {
      solve_bot(mi.top().id, i);
      mi.pop();
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
}
int main() {
  init();
  solve();
  return 0;
}
