#include <bits/stdc++.h>
using namespace std;
struct he {
  int ind;
  int val;
  he(int ind_ = 0, int val_ = 0) : ind(ind_), val(val_) {}
  bool operator<(const he oth) const { return val > oth.val; }
};
int n, m, k;
vector<int> p[200200], c[200200];
int minv[200200], maxv[200200];
int np[200200], nc[200200];
int ans[200200];
queue<int> q;
priority_queue<he> d_cand, id_cand;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if (a == 0) {
      minv[i] = 0;
      maxv[i] = k + 1;
    } else {
      minv[i] = a;
      maxv[i] = a;
    }
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    p[b].push_back(a);
    c[a].push_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    np[i] = p[i].size();
    if (np[i] == 0) {
      maxv[i] = min(k, maxv[i]);
      q.push(i);
    }
  }
  int reached = 0;
  while (!q.empty()) {
    int ind = q.front();
    q.pop();
    ++reached;
    for (int x : c[ind]) {
      maxv[x] = min(maxv[x], maxv[ind] - 1);
      --np[x];
      if (np[x] == 0) q.push(x);
    }
  }
  if (reached < n) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    nc[i] = c[i].size();
    if (nc[i] == 0) {
      id_cand.push(he(i, minv[i]));
    }
  }
  for (int step = 1; step <= k; ++step) {
    while (!id_cand.empty() && id_cand.top().val <= step) {
      int x = id_cand.top().ind;
      id_cand.pop();
      d_cand.push(he(x, maxv[x]));
    }
    if (d_cand.empty()) {
      cout << "-1\n";
      return 0;
    }
    int added = 0;
    while (!d_cand.empty() && d_cand.top().val == step) {
      ++added;
      int x = d_cand.top().ind;
      d_cand.pop();
      ans[x] = step;
      for (int y : p[x]) {
        --nc[y];
        minv[y] = max(minv[y], step + 1);
        if (nc[y] == 0) {
          id_cand.push(he(y, minv[y]));
        }
      }
    }
    if (added == 0) {
      int x = d_cand.top().ind;
      d_cand.pop();
      if (maxv[x] < step) {
        cout << "-1\n";
        return 0;
      }
      ans[x] = step;
      for (int y : p[x]) {
        --nc[y];
        minv[y] = max(minv[y], step + 1);
        if (nc[y] == 0) {
          id_cand.push(he(y, minv[y]));
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
