#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
const int MAXN = 220000;
vector<int> adj[MAXN];
int deg[MAXN], a[MAXN], b[MAXN];
int id[MAXN], ans[MAXN];
void add_edge(int u, int v) {
  adj[u].push_back(v);
  deg[v]++;
}
int q[MAXN];
bool cmp(int u, int v) {
  if (a[u] != a[v]) return a[u] < a[v];
  return b[u] < b[v];
}
set<pair<int, int> > S;
int main() {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i])
      b[i] = a[i];
    else
      b[i] = K;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    if (a[u] && a[v] && a[u] <= a[v]) return puts("-1"), 0;
  }
  for (int i = 1; i <= n; i++)
    if (!a[i]) a[i] = 1, b[i] = K;
  int qn = 0;
  for (int i = 1; i <= n; i++)
    if (!deg[i]) q[qn++] = i;
  for (int it = 0; it < qn; it++) {
    int u = q[it];
    for (int j = 0; j < ((int)(adj[u].size())); j++) {
      int v = adj[u][j];
      if (--deg[v] == 0) q[qn++] = v;
    }
  }
  if (qn != n) {
    return puts("-1"), 0;
  }
  for (int i = 0; i < n; i++) {
    int u = q[i];
    for (int j = 0; j < ((int)(adj[u].size())); j++) {
      int v = adj[u][j];
      chkmin(b[v], b[u] - 1);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int u = q[i];
    for (int j = 0; j < ((int)(adj[u].size())); j++) {
      int v = adj[u][j];
      chkmax(a[u], a[v] + 1);
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i] > b[i]) return puts("-1"), 0;
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1, j = 1; i <= K; i++) {
    while (j <= n && a[id[j]] <= i)
      S.insert(pair<int, int>(b[id[j]], id[j])), j++;
    int flg = 0;
    while (!S.empty()) {
      set<pair<int, int> >::iterator it = S.begin();
      if (it->first > i) break;
      flg = 1;
      int u = it->second;
      ans[u] = i;
      S.erase(it);
    }
    if (!flg && S.empty()) return puts("-1"), 0;
    if (flg) continue;
    set<pair<int, int> >::iterator it = S.begin();
    int u = it->second;
    ans[u] = i;
    S.erase(it);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
