#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int MXN = 2e5 + 5;
int r[MXN];
int perm[MXN];
vector<int> V[MXN], Vi[MXN];
int sto[MXN];
int low[MXN], high[MXN];
void err() {
  printf("-1\n");
  exit(0);
}
bool is[MXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= (n); i++) scanf("%d", &r[i]);
  for (int i = 0; i < (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    V[b].push_back(a);
    Vi[a].push_back(b);
    sto[a]++;
  }
  queue<int> q;
  for (int i = 1; i <= (n); i++)
    if (sto[i] == 0) q.push(i);
  int il = 0;
  while (q.size()) {
    int x;
    perm[++il] = x = q.front();
    q.pop();
    for (auto v : V[x]) {
      sto[v]--;
      if (sto[v] == 0) q.push(v);
    }
  }
  if (il != n) {
    ;
    cout << -1 << endl;
    exit(0);
  }
  set<pair<pair<int, int>, int> > ava;
  for (int i = 1; i <= (n); i++) {
    int v = perm[i];
    if (r[v])
      low[v] = r[v];
    else
      low[v] = 1;
    for (auto c : Vi[v]) {
      ;
      low[v] = max(low[v], low[c] + 1);
    };
  }
  for (int i = n; i >= (1); i--) {
    int v = perm[i];
    if (r[v])
      high[v] = r[v];
    else
      high[v] = k;
    for (auto c : V[v]) {
      ;
      high[v] = min(high[v], high[c] - 1);
    };
  }
  for (int i = 1; i <= (n); i++)
    if (high[i] < low[i]) err();
  vector<pair<int, int> > ranges[MXN];
  for (int i = 1; i <= (n); i++)
    ranges[high[i]].push_back(make_pair(low[i], i));
  for (int i = 1; i <= (n); i++) is[r[i]] = true;
  for (int R = k; R >= (1); R--) {
    for (auto p : ranges[R]) {
      ;
      ava.insert(make_pair(make_pair(p.first, R), p.second));
    }
    if (!is[R]) {
      ;
      while (true) {
        if (ava.empty()) err();
        auto x = ava.end();
        x--;
        auto take = *x;
        ava.erase(x);
        ;
        if (take.first.first <= R && take.first.second >= R) {
          r[take.second] = R;
          break;
        }
      }
    }
  }
  for (int i = 1; i <= (n); i++)
    ;
  ;
  for (int i = n; i >= (1); i--) {
    int v = perm[i];
    if (r[v] == 0) {
      r[v] = k;
      for (auto c : V[v]) r[v] = min(r[v], r[c] - 1);
    }
  }
  for (int i = 1; i <= (n); i++) {
    for (auto j : V[i]) {
      if (r[i] > r[j]) {
        assert(false);
        puts("-1");
        exit(0);
      }
    }
  }
  for (int i = 1; i <= (n); i++) printf("%d ", r[i]);
  printf("\n");
}
