#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const int oo = 1000000000;
int n, m, k, indeg[N], rdeg[N], fr[N], rankk[N], ans[N], is[N], al[N];
vector<int> g[N], p[N];
void no() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  cin >> n >> m >> k;
  if (k > n) no();
  for (int i = 0; i < n; ++i) {
    scanf("%d", &rankk[i]);
    if (rankk[i]) al[i] = 1;
  }
  for (int a, b, i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    ++indeg[b];
    ++rdeg[a];
    g[a].push_back(b);
    p[b].push_back(a);
  }
  queue<int> q;
  for (int i = 0; i < n; ++i)
    if (!indeg[i]) q.push(i);
  int ls = k, cttt = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ++cttt;
    int rk = rankk[u];
    if (!rk) {
      rk = k;
      for (int i = 0; i < p[u].size(); ++i) rk = min(rk, rankk[p[u][i]] - 1);
    }
    rankk[u] = rk;
    is[rk] = 1;
    ls = min(ls, rk);
    for (int i = 0; i < g[u].size(); ++i) {
      if (rankk[g[u][i]] >= rk) no();
      if (!--indeg[g[u][i]]) q.push(g[u][i]);
    }
  }
  if (cttt < n || ls < 1) no();
  set<int> st;
  set<pair<int, int> > oth;
  for (int i = 1; i <= k; ++i)
    if (!is[i]) st.insert(i);
  priority_queue<pair<int, int> > qq;
  for (int i = 0; i < n; ++i) {
    ++fr[rankk[i]];
    if (!rdeg[i]) qq.push(pair<int, int>(-rankk[i], i));
  }
  while (!qq.empty() && !st.empty()) {
    int u = qq.top().second;
    qq.pop();
    bool fff = 1;
    int d = *st.begin();
    if (!al[u] && rankk[u] > d) {
      st.erase(st.begin());
      if (!--fr[rankk[u]]) st.insert(rankk[u]);
      ++fr[d];
      rankk[u] = d;
    } else if (al[u] && rankk[u] > d)
      oth.insert(pair<int, int>(rankk[u], u)), fff = 0;
    if (fff)
      for (int i = 0; i < p[u].size(); ++i)
        if (!--rdeg[p[u][i]]) qq.push(pair<int, int>(-rankk[p[u][i]], p[u][i]));
    while (!oth.empty() && !st.empty() && oth.begin()->first < *st.begin()) {
      qq.push(pair<int, int>(-oth.begin()->first, oth.begin()->second));
      oth.erase(oth.begin());
    }
  }
  if (st.size()) no();
  for (int i = 0; i < n; ++i) printf("%d ", rankk[i]);
  puts("");
}
