#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
struct Tsort {
  int l, t, i;
  bool operator<(const Tsort &t) const { return l < t.l; }
} sor[N];
struct Tedge {
  int v, nxt;
} e[N], e2[N];
int head[N], head2[N], low[N], top[N], key[N], ru[N], ru2[N], ans[N], cnt = 1,
                                                                      n, m, k;
bool fuck[N];
queue<int> q;
void add(int u, int v) {
  e[cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt++;
}
void add2(int u, int v) {
  e2[cnt].v = v;
  e2[cnt].nxt = head2[u];
  head2[u] = cnt++;
}
void init() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &key[i]);
    low[i] = top[i] = key[i];
    if (key[i] == 0) low[i] = 1, top[i] = k;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(v, u);
    add2(u, v);
    ru[u]++;
    ru2[v]++;
  }
}
bool cmp(Tsort a, Tsort b) {
  if (a.t == b.t) return a.l > b.l;
  return a.t > b.t;
}
void solve() {
  for (int i = 1; i <= n; i++)
    if (!ru[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      low[v] = max(low[v], low[u] + 1);
      ru[v]--;
      if (!ru[v]) q.push(v);
    }
  }
  for (int i = 1; i <= n; i++)
    if (ru[i]) {
      printf("-1\n");
      return;
    }
  for (int i = 1; i <= n; i++)
    if (!ru2[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head2[u]; i; i = e2[i].nxt) {
      int v = e2[i].v;
      top[v] = min(top[v], top[u] - 1);
      ru2[v]--;
      if (!ru2[v]) q.push(v);
    }
  }
  for (int i = 1; i <= n; i++)
    if (ru2[i]) {
      printf("-1\n");
      return;
    }
  for (int i = 1; i <= n; i++)
    if (low[i] > top[i]) {
      printf("-1\n");
      return;
    } else {
      sor[i].l = low[i];
      sor[i].t = top[i];
      sor[i].i = i;
    }
  sort(sor + 1, sor + 1 + n, cmp);
  priority_queue<Tsort> qq;
  for (int i = k, pos = 1; i > 0; i--) {
    bool flag = 0;
    while (sor[pos].t >= i) qq.push(sor[pos++]);
    while ((!qq.empty()) && qq.top().l == i) {
      flag = 1;
      ans[qq.top().i] = i, qq.pop();
    }
    if (!flag) {
      if (!qq.empty())
        ans[qq.top().i] = i, qq.pop();
      else {
        printf("-1\n");
        return;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  init();
  solve();
  return 0;
}
