#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
const int MAXRANK = 200000;
struct P {
  int mxrank, mnrank, id;
};
bool operator<(const P &a, const P &b) {
  if (a.mxrank != b.mxrank) return a.mxrank > b.mxrank;
  return a.id < b.id;
}
int n, m, nrank;
int fixedrank[MAXN];
vector<int> e[MAXN];
vector<int> re[MAXN];
P p[MAXN];
int ans[MAXN];
queue<int> q[MAXRANK];
int deg[MAXN];
void calcmxrank() {
  for (int i = (0); i < (nrank); ++i) q[i] = queue<int>();
  for (int i = (0); i < (n); ++i)
    deg[i] = ((int)(re[i]).size()), p[i].mxrank = -1;
  for (int i = (0); i < (n); ++i)
    if (deg[i] == 0) {
      int x = fixedrank[i] == -1 ? nrank - 1 : fixedrank[i];
      q[x].push(i);
    }
  for (int r = nrank - 1; r >= 0; --r) {
    while (!q[r].empty()) {
      int at = q[r].front();
      q[r].pop();
      p[at].mxrank = r;
      for (int i = (0); i < (((int)(e[at]).size())); ++i) {
        int to = e[at][i];
        if (--deg[to] == 0) {
          int x = fixedrank[to] == -1 ? r - 1 : fixedrank[to];
          if (0 <= x && x < r) q[x].push(to);
        }
      }
    }
  }
}
void calcmnrank() {
  for (int i = (0); i < (nrank); ++i) q[i] = queue<int>();
  for (int i = (0); i < (n); ++i)
    deg[i] = ((int)(e[i]).size()), p[i].mnrank = -1;
  for (int i = (0); i < (n); ++i)
    if (deg[i] == 0) {
      int x = fixedrank[i] == -1 ? 0 : fixedrank[i];
      q[x].push(i);
    }
  for (int r = (0); r < (nrank); ++r) {
    while (!q[r].empty()) {
      int at = q[r].front();
      q[r].pop();
      p[at].mnrank = r;
      for (int i = (0); i < (((int)(re[at]).size())); ++i) {
        int to = re[at][i];
        if (--deg[to] == 0) {
          int x = fixedrank[to] == -1 ? r + 1 : fixedrank[to];
          if (r < x && x < nrank) q[x].push(to);
        }
      }
    }
  }
}
priority_queue<pair<int, int> > pq;
bool calcans() {
  sort(p, p + n);
  pq = priority_queue<pair<int, int> >();
  int at = 0;
  for (int r = nrank - 1; r >= 0; --r) {
    while (at < n && p[at].mxrank == r) {
      pq.push(make_pair(p[at].mnrank, -p[at].id));
      ++at;
    }
    if (pq.empty()) return false;
    int cur = -pq.top().second;
    pq.pop();
    ans[cur] = r;
    while (!pq.empty() && pq.top().first == r) {
      int oth = -pq.top().second;
      pq.pop();
      ans[oth] = r;
    }
  }
  return true;
}
bool solve() {
  for (int i = (0); i < (n); ++i) p[i].id = i;
  calcmxrank();
  calcmnrank();
  for (int i = (0); i < (n); ++i)
    if (p[i].mnrank == -1 || p[i].mxrank == -1 || p[i].mnrank > p[i].mxrank)
      return false;
  return calcans();
}
void run() {
  scanf("%d%d%d", &n, &m, &nrank);
  for (int i = (0); i < (n); ++i) scanf("%d", &fixedrank[i]), --fixedrank[i];
  for (int i = (0); i < (m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    e[a].push_back(b);
    re[b].push_back(a);
  }
  if (!solve()) {
    printf("-1\n");
    return;
  }
  for (int i = (0); i < (n); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ans[i] + 1);
  }
  puts("");
}
int main() {
  run();
  return 0;
}
