#include <bits/stdc++.h>
using namespace std;
template <class T>
bool cmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool cmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int N = 2e5 + 10;
int n, m, nranks;
vector<int> E[N];
int deg[N];
int q[N], qh, qt;
int l[N], r[N];
int cnt[N];
vector<int> nodes[N];
void lose() {
  puts("-1");
  exit(EXIT_SUCCESS);
}
int main() {
  scanf("%d%d%d", &n, &m, &nranks);
  for (int i = 1; i <= n; i++) scanf("%d", l + i);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    E[u].push_back(v);
    deg[v]++;
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 0) q[qt++] = i;
    if (l[i] == 0)
      l[i] = 1, r[i] = nranks;
    else
      cnt[r[i] = l[i]]++;
  }
  while (qh < qt) {
    int u = q[qh++];
    for (int v : E[u])
      if (--deg[v] == 0) q[qt++] = v;
  }
  if (qt != n) {
    lose();
  }
  for (int qi = 0; qi < n; qi++) {
    {
      int u = q[qi];
      for (int v : E[u]) cmin(r[v], r[u] - 1);
    }
    {
      int u = q[n - qi - 1];
      for (int v : E[u]) cmax(l[u], l[v] + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] > r[i]) lose();
    nodes[l[i]].push_back(i);
  }
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  for (int rnk = 1; rnk <= nranks; rnk++) {
    for (int u : nodes[rnk]) pq.push({r[u], u});
    if (cnt[rnk] == 0) {
      if (pq.empty()) lose();
      l[pq.top().second] = rnk;
      pq.pop();
    }
    while (!pq.empty() && pq.top().first == rnk) {
      l[pq.top().second] = rnk;
      pq.pop();
    }
  }
  for (int i = 1; i <= n; i++) printf("%d%c", l[i], " \n"[i == n]);
  for (int i = 1; i <= n; i++) {
    for (int v : E[i]) {
      if (l[i] <= l[v]) {
        printf("(%d, %d)\n", i, v);
      }
      assert(l[i] > l[v]);
    }
  }
  return 0;
}
