#include <bits/stdc++.h>
using namespace std;
template <class T>
void chkmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chkmin(T &a, T b) {
  if (a > b) a = b;
}
int n, m, up;
int a[200005], b[200005], bs;
int head[200005], to[200005], nxt[200005];
int mn[200005], mx[200005];
int G, vis[200005], tot;
void add_edge(int first, int second) {
  tot++;
  to[tot] = second;
  nxt[tot] = head[first];
  head[first] = tot;
  return;
}
bool dfs(int k) {
  vis[k] = 1;
  int first;
  for (int i = head[k]; i; i = nxt[i]) {
    first = to[i];
    if (vis[first] == 2)
      continue;
    else if (vis[first] || dfs(first))
      return 1;
  }
  vis[k] = 2;
  b[++bs] = k;
  return 0;
}
vector<int> v[200005];
int main() {
  int first, second;
  scanf("%d %d %d", &n, &m, &up);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &first, &second);
    add_edge(first, second);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i] && dfs(i)) {
      puts("-1");
      return 0;
    }
  bool flag = 0;
  for (int j = 1; j <= bs && !flag; j++) {
    int k = b[j];
    mn[k] = 1;
    for (int i = head[k]; i; i = nxt[i]) chkmax(mn[k], mn[to[i]] + 1);
    if (a[k] && mn[k] > a[k])
      flag = 1;
    else if (a[k])
      mn[k] = a[k];
  }
  for (int i = 1; i <= n; i++) mx[i] = up;
  for (int j = bs; j && !flag; j--) {
    int k = b[j];
    if (a[k] && mx[k] < a[k])
      flag = 1;
    else if (a[k])
      mx[k] = a[k];
    for (int i = head[k]; i; i = nxt[i]) chkmin(mx[to[i]], mx[k] - 1);
  }
  for (int i = 1; i <= n; i++)
    if (mn[i] > mx[i]) flag = 1;
  if (up > n) flag = 1;
  if (flag)
    puts("-1");
  else {
    for (int i = 1; i <= n; i++) v[mn[i]].push_back(i);
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        pq;
    for (int i = 1; i <= up; i++) {
      for (int j = 0; j < v[i].size(); j++)
        pq.push(pair<int, int>(mx[v[i][j]], v[i][j]));
      if (pq.empty()) {
        puts("-1");
        return 0;
      }
      pair<int, int> rpt = pq.top();
      pq.pop();
      a[rpt.second] = i;
      while (!pq.empty()) {
        rpt = pq.top();
        if (rpt.first == i)
          a[rpt.second] = i, pq.pop();
        else
          break;
      }
    }
    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  }
  return 0;
}
