#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, k, a[N], deg[N], id[N], cnt, mi[N], mx[N], ans[N];
bool used[N];
vector<int> g[N], r[N];
vector<pair<int, int> > v[N];
queue<int> q;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i])
      used[mx[i] = mi[i] = a[i]];
    else {
      mx[i] = k;
      mi[i] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    r[v].push_back(u);
    deg[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (!deg[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    id[++cnt] = u;
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i];
      if (!(--deg[v])) q.push(v);
    }
  }
  if (cnt < n) {
    cout << "-1\n";
    return 0;
  }
  for (int it = n, i; it; it--) {
    i = id[it];
    for (int j = 0; j < g[i].size(); j++) mi[i] = max(mi[i], mi[g[i][j]] + 1);
  }
  for (int it = 1, i; it <= n; it++) {
    i = id[it];
    for (int j = 0; j < r[i].size(); j++) mx[i] = min(mx[i], mx[r[i][j]] - 1);
  }
  for (int i = 1; i <= n; i++) {
    if (mi[i] > mx[i]) {
      cout << "-1\n";
      return 0;
    }
    v[mi[i]].push_back(pair<int, int>(mx[i], i));
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < v[i].size(); j++) pq.push(v[i][j]);
    if (!used[i]) {
      if (pq.empty()) {
        cout << "-1\n";
        return 0;
      }
      ans[pq.top().second] = i;
      pq.pop();
    }
    while (!pq.empty() && pq.top().first == i) {
      ans[pq.top().second] = i;
      pq.pop();
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
