#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 10;
int n, m, k, a[N], deg1[N], deg2[N];
int L[N], R[N], vis[N];
int first[N], second[N], b[N];
vector<int> g1[N], g2[N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (a[i])
      L[i] = R[i] = a[i];
    else
      L[i] = 1, R[i] = k;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", first + i, second + i);
    g2[first[i]].push_back(second[i]), ++deg2[second[i]];
    g1[second[i]].push_back(first[i]), ++deg1[first[i]];
  }
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (!deg1[i]) q.push(i);
  int cnt = 0;
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (L[u] > R[u]) return puts("-1"), 0;
    ++cnt;
    for (auto &v : g1[u]) {
      L[v] = max(L[v], L[u] + 1);
      if (!--deg1[v]) q.push(v);
    }
  }
  if (cnt != n) return puts("-1"), 0;
  for (int i = 1; i <= n; ++i)
    if (!deg2[i]) q.push(i);
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (L[u] > R[u]) return puts("-1"), 0;
    for (auto &v : g2[u]) {
      R[v] = min(R[v], R[u] - 1);
      if (!--deg2[v]) q.push(v);
    }
  }
  for (int i = 1; i <= n; ++i) b[i] = i;
  sort(b + 1, b + 1 + n, [](int a, int b) { return L[a] < L[b]; });
  int now = 1;
  set<pair<int, int> > s;
  for (int i = 1; i <= k; ++i) {
    while (now <= n && L[b[now]] <= i) {
      s.insert(pair<int, int>(R[b[now]], b[now]));
      ++now;
    }
    int ok = 0;
    while (s.size()) {
      int id = s.begin()->second;
      if (ok && R[id] > i) break;
      ok = 1;
      s.erase(s.begin());
      a[id] = i;
    }
    if (!ok) return puts("-1"), 0;
  }
  for (int i = 1; i <= n; ++i) printf("%d ", a[i] ? a[i] : L[i]);
  putchar(10);
}
