#include <bits/stdc++.h>
const int N = 200005;
int n, m, k, ans[N], deg[N];
int min[N], max[N], u[N], v[N];
std::vector<int> g[N];
void link(int x, int y) { g[x].emplace_back(y), ++deg[y]; }
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m >> k;
  for (int i = 1, x; i <= n; ++i) {
    std::cin >> x, min[i] = 1, max[i] = k;
    if (x) min[i] = max[i] = x;
  }
  for (int i = 1; i <= m; ++i) std::cin >> u[i] >> v[i], link(u[i], v[i]);
  std::queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) q.push(i);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int y : g[x]) {
      max[y] = std::min(max[y], max[x] - 1);
      if (!--deg[y]) q.push(y);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (deg[i] || min[i] > max[i]) return std::cout << "-1\n", 0;
  for (int i = 1; i <= n; ++i) g[i].clear();
  for (int i = 1; i <= m; ++i) link(v[i], u[i]);
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) q.push(i);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int y : g[x]) {
      min[y] = std::max(min[y], min[x] + 1);
      if (!--deg[y]) q.push(y);
    }
  }
  for (int i = 1; i <= n; ++i) g[i].clear();
  for (int i = 1; i <= n; ++i) g[min[i]].emplace_back(i);
  std::priority_queue<std::pair<int, int>> pq;
  for (int i = 1; i <= k; ++i) {
    for (int j : g[i]) pq.emplace(-max[j], j);
    if (pq.empty()) return std::cout << "-1\n", 0;
    do {
      int x = pq.top().second;
      pq.pop(), ans[x] = i;
    } while (pq.size() && pq.top().first == -i);
  }
  for (int i = 1; i <= n; ++i) std::cout << ans[i] << ' ';
  std::cout << '\n';
  return 0;
}
