#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m, k;
vector<int> g[maxn], rg[maxn];
int rak[maxn], in[maxn], out[maxn], up[maxn], dn[maxn];
int sta[maxn], rsta[maxn], ind[maxn], col[maxn];
bool usd[maxn];
int cc;
void dfs(int x, int c) {
  sta[x] = 1;
  col[x] = c;
  for (int i = (0); i < (int)(g[x].size()); ++i) {
    int to = g[x][i];
    if (sta[to] == 1) {
      printf("-1\n");
      exit(0);
    }
    up[to] = (up[to] < up[x] - 1 ? up[to] : up[x] - 1);
    dfs(to, c);
  }
  sta[x] = 2;
}
void rdfs(int x, int c) {
  rsta[x] = 1;
  col[x] = c;
  for (int i = (0); i < (int)(rg[x].size()); ++i) {
    int fr = rg[x][i];
    if (rsta[fr] == 1) {
      printf("-1\n");
      exit(0);
    }
    dn[fr] = max(dn[fr], dn[x] + 1);
    rdfs(fr, c);
  }
  rsta[x] = 2;
}
bool less2(int a, int b) {
  if (dn[a] != dn[b]) return dn[a] < dn[b];
  return up[a] < up[b];
}
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    A, B;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int free = 0;
  for (int i = (0); i < (int)(n); ++i) {
    scanf("%d", &rak[i]);
    if (!rak[i])
      free++;
    else
      usd[rak[i]] = 1;
  }
  for (int i = (0); i < (int)(m); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    out[x]++, in[y]++;
    g[x].push_back(y);
    rg[y].push_back(x);
  }
  for (int i = (1); i < (int)(k + 1); ++i)
    if (!usd[i]) free--;
  if (free < 0) {
    printf("-1\n");
    return 0;
  }
  memset(up, 0x3f, sizeof(up));
  for (int i = (0); i < (int)(n); ++i) {
    ind[i] = i;
    if (rak[i]) up[i] = dn[i] = rak[i];
  }
  cc = 1;
  for (int i = (0); i < (int)(n); ++i) {
    if (!in[i]) {
      if (!rak[i]) up[i] = k;
      dfs(i, cc++);
    }
    if (!out[i]) {
      if (!rak[i]) dn[i] = 1;
      rdfs(i, cc++);
    }
  }
  for (int i = (0); i < (int)(n); ++i)
    if (!sta[i] && !rsta[i]) {
      printf("-1\n");
      return 0;
    }
  for (int i = (0); i < (int)(n); ++i)
    if (up[i] < dn[i] || (rak[i] && (rak[i] < dn[i] || rak[i] > up[i]))) {
      printf("-1\n");
      return 0;
    }
  for (int i = (0); i < (int)(n); ++i) {
    ind[i] = i;
    if (rak[i]) up[i] = dn[i] = rak[i];
  }
  for (int i = (0); i < (int)(n); ++i)
    A.push(make_pair(dn[i], make_pair(up[i], i)));
  for (int i = (1); i < (int)(k + 1); ++i) {
    while (!A.empty() && A.top().first <= i) {
      pair<int, pair<int, int> > x = A.top();
      A.pop();
      swap(x.first, x.second.first);
      B.push(x);
    }
    rak[B.top().second.second] = i;
    B.pop();
    while (!B.empty() && B.top().first == i) {
      rak[B.top().second.second] = i;
      B.pop();
    }
  }
  for (int i = (0); i < (int)(n); ++i)
    printf("%d%c", rak[i], i == n - 1 ? '\n' : ' ');
  return 0;
}
