#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct P {
  int x, y, id;
  bool operator<(const P b) const { return y > b.y; }
} a[N];
bool cmp(P a, P b) { return a.x < b.x; }
vector<int> link[N];
bool vis[N];
int d[N];
int L[N], R[N];
int ans[N];
void dfs(int u) {
  vis[u] = 1;
  for (int v : link[u]) {
    if (!vis[v]) dfs(v);
    L[u] = max(L[u], L[v] + 1);
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x)
      L[i] = R[i] = x;
    else
      L[i] = 1, R[i] = k;
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    link[x].push_back(y);
    d[y]++;
  }
  for (int i = 1; i <= n; i++)
    if (d[i] == 0) dfs(i);
  queue<int> Q;
  for (int i = 1; i <= n; i++)
    if (d[i] == 0) Q.push(i);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int v : link[u]) {
      R[v] = min(R[v], R[u] - 1);
      d[v]--;
      if (d[v] == 0) Q.push(v);
    }
  }
  for (int i = 1; i <= n; i++)
    if (d[i]) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= n; i++)
    if (L[i] > R[i]) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= n; i++) a[i] = {L[i], R[i], i};
  sort(a + 1, a + n + 1, cmp);
  priority_queue<P> PQ;
  int j = 1;
  for (int i = 1; i <= k; i++) {
    while (j <= n && a[j].x <= i) PQ.push(a[j]), j++;
    bool gt = 0;
    while (!PQ.empty()) {
      P tmp = PQ.top();
      PQ.pop();
      if (tmp.y < i) continue;
      ans[tmp.id] = i;
      gt = 1;
      break;
    }
    if (!gt) {
      printf("-1\n");
      return 0;
    }
    while (!PQ.empty()) {
      P tmp = PQ.top();
      if (tmp.y == i) {
        ans[tmp.id] = i;
        PQ.pop();
      } else
        break;
    }
  }
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", ans[i]);
}
