#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
namespace Heap {
std::pair<int, int> pool[MAXN];
int tot;
void init() { tot = 0; }
std::pair<int, int> top() { return pool[1]; }
void push(int x, int y) {
  pool[++tot] = std::make_pair(x, y);
  std::push_heap(pool + 1, pool + tot + 1,
                 std::greater<std::pair<int, int> >());
}
void pop() {
  std::pop_heap(pool + 1, pool + tot + 1, std::greater<std::pair<int, int> >());
  --tot;
}
bool empty() { return tot == 0; }
}  // namespace Heap
int n, m, k;
int L[MAXN], R[MAXN];
std::vector<int> G[MAXN], vL[MAXN];
int ideg[MAXN];
int que[MAXN], hd = 0, tl = 0;
int ans[MAXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    static int x;
    scanf("%d", &x);
    if (x)
      L[i] = R[i] = x;
    else
      L[i] = 1, R[i] = k;
  }
  for (int i = 1; i <= m; ++i) {
    static int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    ++ideg[y];
  }
  for (int i = 1; i <= n; ++i)
    if (!ideg[i]) que[++tl] = i;
  while (hd != tl) {
    int now = que[++hd];
    for (int to : G[now])
      if (!--ideg[to]) que[++tl] = to;
  }
  if (tl != n) return puts("-1"), 0;
  for (int i = 1; i <= n; ++i) {
    int now = que[i];
    for (int to : G[now]) R[to] = std::min(R[to], R[now] - 1);
  }
  for (int i = n; i; --i) {
    int now = que[i];
    for (int to : G[now]) L[now] = std::max(L[now], L[to] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (L[i] > R[i]) return puts("-1"), 0;
    vL[L[i]].push_back(i);
  }
  for (int i = 1; i <= k; ++i) {
    for (int x : vL[i]) Heap::push(R[x], x);
    if (Heap::empty()) return puts("-1"), 0;
    ans[Heap::top().second] = i;
    Heap::pop();
    while (!Heap::empty() && Heap::top().first == i) {
      ans[Heap::top().second] = i;
      Heap::pop();
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
  return 0;
}
