#include <bits/stdc++.h>
using namespace std;
int n, m, k, tot, head[200010], mx[200010], mn[200010], out[200010], in[200010],
    F[200010];
int c[200010], cnt = 1, b[200010], first, last;
struct rd {
  int next, to, f;
} road[400010];
struct node {
  int x, y, id;
  bool operator<(const node &a) const { return a.y < y; }
} a[200010];
inline bool cmp(node a, node b) { return a.x < b.x; }
priority_queue<node> q;
bool flag[200010];
inline void addedge(int x, int y, int z) {
  road[++tot].next = head[x];
  road[tot].to = y;
  road[tot].f = z;
  head[x] = tot;
}
inline void work1() {
  first = 1, last = 0;
  for (int i = 1; i <= n; i++)
    if (in[i] == 0) F[++last] = i;
  while (first <= last) {
    int x = F[first];
    flag[x] = 1;
    for (int now = head[x]; now; now = road[now].next)
      if (road[now].f == 1) {
        mx[road[now].to] = min(mx[road[now].to], mx[x] - 1);
        if (--in[road[now].to] == 0) F[++last] = road[now].to;
      }
    first++;
  }
}
inline void work2() {
  first = 1, last = 0;
  for (int i = 1; i <= n; i++)
    if (out[i] == 0) F[++last] = i;
  while (first <= last) {
    int x = F[first];
    for (int now = head[x]; now; now = road[now].next)
      if (road[now].f == -1) {
        mn[road[now].to] = max(mn[road[now].to], mn[x] + 1);
        if (--out[road[now].to] == 0) F[++last] = road[now].to;
      }
    first++;
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y, 1);
    addedge(y, x, -1);
    out[x]++;
    in[y]++;
  }
  for (int i = 1; i <= n; i++)
    if (c[i] == 0)
      mn[i] = 1, mx[i] = k;
    else
      mn[i] = mx[i] = c[i];
  work1();
  for (int i = 1; i <= n; i++)
    if (flag[i] == 0 || mn[i] > mx[i]) {
      printf("-1\n");
      return 0;
    }
  work2();
  for (int i = 1; i <= n; i++) a[i] = (node){mn[i], mx[i], i};
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1, j = 1; i <= k; i++) {
    while (j <= n && a[j].x <= i) q.push(a[j]), j++;
    int kill = 0;
    while (!q.empty()) {
      if (q.top().y == i || kill == 0)
        b[q.top().id] = i, kill = 1, q.pop();
      else
        break;
    }
    if (kill == 0) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = last; i >= 1; i--) {
    int x = F[i];
    if (b[x] > mx[x] || b[x] < mn[x]) {
      printf("-1\n");
      return 0;
    }
    for (int now = head[x]; now; now = road[now].next)
      if (road[now].f == 1) b[road[now].to] = min(b[road[now].to], b[x] - 1);
  }
  for (int i = 1; i <= n; i++) printf("%d ", b[i]);
  return 0;
}
