#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, k, a[N], b[N];
int deg[N], q[N], vis[N], fa[N];
vector<int> e[N], v[N];
int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &a[i]);
  for (int i = (int)(1); i <= (int)(n); i++) b[i] = (a[i] ? a[i] : k);
  for (int i = (int)(1); i <= (int)(m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    ++deg[y];
  }
  int h = 0, t = 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (!deg[i]) q[++t] = i;
  while (h != t) {
    int x = q[++h];
    if ((a[x] && b[x] < a[x]) || b[x] < 1) return puts("-1"), 0;
    for (auto i : e[x]) {
      b[i] = min(b[i], b[x] - 1);
      if (!--deg[i]) q[++t] = i;
    }
  }
  if (t != n) return puts("-1"), 0;
  for (int i = (int)(1); i <= (int)(n); i++) v[b[i]].push_back(i);
  for (int i = (int)(1); i <= (int)(k); i++) fa[i] = i;
  for (int i = (int)(1); i <= (int)(k); i++) {
    for (auto j : v[i]) {
      if (a[j]) {
        vis[i] = 1;
        continue;
      }
      int r = 0;
      for (auto k : e[j]) r = max(r, b[k]);
      r = get(r + 1);
      if (r != i) fa[r] = r + 1;
      b[j] = r;
      vis[r] = 1;
    }
    if (vis[i]) fa[i] = i + 1;
  }
  for (int i = (int)(1); i <= (int)(k); i++)
    if (!vis[i]) return puts("-1"), 0;
  for (int i = (int)(1); i <= (int)(n); i++) printf("%d ", b[i]);
}
