#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200002;
int n, m, k;
int assigned_rank[MAXN];
vector<int> adj[MAXN];
int min_rank[MAXN];
int topo_order[MAXN];
int active_orders[MAXN];
set<int> people_by_rank[MAXN];
priority_queue<pair<int, int>> pq;
int countv;
int visited[MAXN];
bool topodfs(int v) {
  if (visited[v] == 2) return true;
  if (visited[v] == 1) return false;
  visited[v] = 1;
  for (int u : adj[v])
    if (!topodfs(u)) return false;
  topo_order[++countv] = v;
  visited[v] = 2;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> assigned_rank[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    active_orders[y]++;
  }
  countv = 0;
  for (int i = 1; i <= n; i++)
    if (0 == visited[i])
      if (!topodfs(i)) {
        cout << "-1\n";
        return 0;
      }
  for (int i = 1; i <= n; i++) {
    int v = topo_order[i];
    min_rank[v] = 1;
    for (int u : adj[v]) min_rank[v] = max(min_rank[v], 1 + min_rank[u]);
    if (assigned_rank[v] > 0) {
      if (min_rank[v] > assigned_rank[v]) {
        cout << "-1\n";
        return 0;
      }
      min_rank[v] = assigned_rank[v];
    }
    if (min_rank[v] > k) {
      cout << "-1\n";
      return 0;
    }
    people_by_rank[min_rank[v]].insert(v);
    if (active_orders[v] == 0 && assigned_rank[v] == 0)
      pq.emplace(min_rank[v], v);
  }
  for (int r = k; r > 0; r--) {
    if (people_by_rank[r].empty()) {
      while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        int u = p.second;
        if (min_rank[u] > r) continue;
        people_by_rank[min_rank[u]].erase(u);
        people_by_rank[r].insert(u);
        min_rank[u] = r;
        break;
      }
      if (people_by_rank[r].empty()) {
        cout << "-1\n";
        return 0;
      }
    }
    for (int v : people_by_rank[r]) {
      for (int u : adj[v]) {
        active_orders[u]--;
        if (active_orders[u] == 0 && assigned_rank[u] == 0)
          pq.emplace(min_rank[u], u);
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << min_rank[i] << ' ';
  cout << '\n';
  return 0;
}
