#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
const long long int mod = 1000000007ll;
vector<int> alive[300005];
vector<int> adj[300005];
vector<int> radj[300005];
int col[300005];
int val[300005];
int deg[300005];
bool possible(int n, int k) {
  queue<int> qu;
  for (int i = 1; i <= n; i++) {
    deg[i] = adj[i].size();
    if (deg[i] == 0) {
      qu.push(i);
      if (col[i] == 0)
        val[i] = 1;
      else
        val[i] = col[i];
    }
  }
  while (!qu.empty()) {
    int u = qu.front();
    qu.pop();
    if (col[u] != 0) {
      if (val[u] > col[u]) return false;
      val[u] = col[u];
    }
    for (int i = 0; i < radj[u].size(); i++) {
      int v = radj[u][i];
      deg[v]--;
      val[v] = max(val[v], val[u] + 1);
      if (deg[v] == 0) {
        qu.push(v);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (val[i] == 0 || val[i] > k) return false;
  }
  return true;
}
int cnt[300005];
bool solve(int n, int k) {
  priority_queue<pair<int, int> > qu;
  for (int i = 1; i <= n; i++) {
    deg[i] = radj[i].size();
    if (deg[i] == 0) {
      if (col[i] == 0)
        qu.push(make_pair(val[i], i));
      else
        alive[col[i]].push_back(i);
    }
    cnt[val[i]]++;
  }
  int make = k;
  while (make > 0) {
    while (make > 0 && cnt[make] != 0) {
      for (int i = 0; i < alive[make].size(); i++)
        qu.push(make_pair(val[alive[make][i]], alive[make][i]));
      make--;
    }
    if (qu.empty()) return false;
    int u = qu.top().second;
    qu.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      deg[v]--;
      if (deg[v] == 0) {
        if (col[v] == 0 || col[v] >= make)
          qu.push(make_pair(val[v], v));
        else {
          alive[col[v]].push_back(v);
        }
      }
    }
    if (make == 0) continue;
    if (val[u] >= make || col[u] != 0) continue;
    cnt[val[u]]--;
    val[u] = make;
    cnt[val[u]]++;
  }
  memset(deg, 0, sizeof deg);
  for (int i = 1; i <= n; i++) deg[val[i]]++;
  for (int i = 1; i <= k; i++)
    if (deg[i] == 0) return false;
  return true;
}
int main() {
  int n, m, k, u, v;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &col[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    radj[v].push_back(u);
  }
  if (!possible(n, k)) {
    puts("-1");
    return 0;
  }
  if (!solve(n, k)) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) printf("%d ", val[i]);
  puts("");
  return 0;
}
