#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> order, g[N], g2[N];
int dg[N], dp[N], n, m, k, e[N];
int32_t main() {
  scanf("%d%d%d", &n, &m, &k);
  set<int> miss;
  for (int i = 1; i <= k; i++) miss.insert(i);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &e[i]);
    miss.erase(e[i]);
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[y].push_back(x);
    g2[x].push_back(y);
    dg[x]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!dg[i]) order.push_back(i);
  }
  for (int i = 0; i < (int)(order).size(); i++) {
    auto v = order[i];
    for (auto w : g[v]) {
      if (--dg[w] == 0) order.push_back(w);
    }
  }
  if ((int)(order).size() != n) {
    puts("-1");
    return 0;
  }
  reverse(begin(order), end(order));
  vector<pair<int, int> > ord;
  for (int i = 0; i < (int)(order).size(); i++) {
    int has = k;
    auto v = order[i];
    for (auto w : g[v]) {
      has = min(has, dp[w] - 1);
    }
    dp[v] = has;
    if (e[v]) {
      if (dp[v] < e[v]) {
        puts("-1");
        return 0;
      }
      dp[v] = e[v];
    }
    if (dp[v] < 1) {
      puts("-1");
      return 0;
    }
    if (!e[v]) {
      ord.push_back({dp[v], v});
    }
  }
  cout << endl;
  sort(begin(ord), end(ord));
  for (auto w : ord) {
    int la = 1;
    for (auto wk : g2[w.second]) {
      la = max(la, e[wk] + 1);
    }
    auto fa = miss.lower_bound(la);
    if (fa == end(miss)) {
      e[w.second] = w.first;
    } else {
      e[w.second] = min(w.first, *fa);
    }
    miss.erase(e[w.second]);
  }
  for (int i = 1; i <= n; i++) {
    for (auto w : g2[i]) {
      if (e[i] <= e[w]) {
        puts("-1");
        return 0;
      }
    }
  }
  if ((int)(miss).size()) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", e[i]);
  }
  printf("\n");
}
