#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = (long long)(1e18) + 100;
const int MAXN = 2e5 + 10;
int n, m, k;
int minr[MAXN], deg[MAXN], color[MAXN], maxr[MAXN], vis[MAXN];
vector<int> adj[MAXN], order[MAXN];
bool ok;
void dfs(int v) {
  int mn = 1;
  vis[v] = 1;
  for (int x : adj[v]) {
    if (!vis[x]) dfs(x);
    mn = max(mn, minr[x] + 1);
  }
  if (minr[v] != 0) {
    if (mn > minr[v]) ok = 0;
  } else
    minr[v] = mn;
  if (mn > k) ok = 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> color[i];
    minr[i] = color[i];
  }
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    deg[y]++;
    adj[x].push_back(y);
  }
  memset(maxr, INF, sizeof maxr);
  for (int i = 1; i <= n; i++)
    if (minr[i] > 0) maxr[i] = minr[i];
  queue<int> fila;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0) {
      fila.push(i);
      maxr[i] = min(maxr[i], k);
      order[maxr[i]].push_back(i);
    }
  int cnt = 0, vtx;
  while (!fila.empty()) {
    vtx = fila.front();
    fila.pop();
    cnt++;
    for (int x : adj[vtx]) {
      deg[x]--;
      maxr[x] = min(maxr[x], maxr[vtx] - 1);
      if (deg[x] == 0) {
        fila.push(x);
        if (maxr[x] <= 0) {
          cout << -1 << '\n';
          return 0;
        }
        order[maxr[x]].push_back(x);
      }
    }
  }
  if (cnt != n) {
    cout << -1 << '\n';
    return 0;
  }
  ok = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  if (!ok) {
    cout << -1 << '\n';
    return 0;
  }
  priority_queue<pair<int, int> > pq;
  for (int rnk = k; rnk > 0; rnk--) {
    for (auto x : order[rnk]) pq.push({minr[x], x});
    if (pq.empty()) {
      cout << -1 << '\n';
      return 0;
    }
    do {
      color[pq.top().second] = rnk;
      pq.pop();
    } while (!pq.empty() and pq.top().first == rnk);
  }
  for (int i = 1; i <= n; i++) cout << color[i] << ' ';
  cout << '\n';
}
