#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, m, k, deg[N], seq[N], tt, l[N], r[N], ans[N];
vector<int> E[N], vec[N];
void No() {
  cout << -1;
  exit(0);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    r[i] = gi();
    if (r[i])
      l[i] = r[i];
    else
      l[i] = 1, r[i] = k;
  }
  for (int i = 1, u, v; i <= m; i++)
    u = gi(), v = gi(), E[u].push_back(v), ++deg[v];
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (!deg[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    seq[++tt] = u;
    for (auto v : E[u])
      if (!--deg[v]) q.push(v);
  }
  if (tt != n) No();
  for (int i = 1; i <= n; i++) {
    int u = seq[i];
    for (auto v : E[u]) r[v] = min(r[v], r[u] - 1);
  }
  for (int i = n; i; i--) {
    int u = seq[i];
    for (auto v : E[u]) l[u] = max(l[u], l[v] + 1);
  }
  for (int i = 1; i <= n; i++) {
    if (l[i] > r[i]) No();
    vec[l[i]].push_back(i);
  }
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      Q;
  for (int i = 1; i <= k; i++) {
    for (auto t : vec[i]) Q.push(make_pair(r[t], t));
    if (Q.empty()) No();
    do {
      ans[Q.top().second] = i;
      Q.pop();
    } while (!Q.empty() && Q.top().first == i);
  }
  for (int u = 1; u <= n; u++)
    for (auto v : E[u]) assert(ans[u] > ans[v]);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
