#include <bits/stdc++.h>
using namespace std;
void dfs(int x, const vector<vector<int> > &g, vector<char> &used,
         vector<int> &order) {
  used[x] = 1;
  for (int dest : g[x])
    if (!used[dest]) dfs(dest, g, used, order);
  order.push_back(x);
}
void solve(int n) {
  int m, k;
  cin >> m >> k;
  vector<int> rk(n);
  vector<char> isset(n);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> rk[i];
    isset[i] = (rk[i] == 0 ? 0 : 1);
  }
  vector<vector<int> > g(n), grev(n);
  for (int i = 0; i < (int)(m); ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[v].push_back(u);
    grev[u].push_back(v);
  }
  vector<int> order;
  {
    vector<char> used(n);
    for (int i = 0; i < (int)(n); ++i)
      if (!used[i]) dfs(i, g, used, order);
    reverse((order).begin(), (order).end());
    vector<int> in_order(n);
    for (int i = 0; i < (int)(n); ++i) in_order[order[i]] = i;
    for (int i = 0; i < (int)(n); ++i)
      for (int to : g[i])
        if (in_order[i] > in_order[to]) {
          cout << -1 << endl;
          return;
        }
    for (int v : order) {
      if (rk[v] == 0) rk[v] = 1;
      if (rk[v] > k) {
        cout << -1 << endl;
        return;
      }
      for (int to : g[v]) {
        if (isset[to] && rk[to] < rk[v] + 1) {
          cout << -1 << endl;
          return;
        } else if (!isset[to])
          rk[to] = max(rk[to], rk[v] + 1);
      }
    }
  }
  set<pair<int, int> > fixed, unfix;
  vector<int> out(n);
  for (int i = 0; i < (int)(n); ++i) out[i] = (int)(g[i]).size();
  vector<int> oldrk = rk;
  auto add_ver = [&](int x) {
    if (out[x] <= 0) (isset[x] ? fixed : unfix).insert(make_pair(oldrk[x], x));
  };
  auto del_ver = [&](int x) {
    (isset[x] ? fixed : unfix).erase(make_pair(oldrk[x], x));
    for (int from : grev[x]) {
      out[from]--;
      assert(oldrk[from] < oldrk[x]);
      add_ver(from);
    }
  };
  for (int i = 0; i < (int)(n); ++i) add_ver(i);
  for (int currank = ((int)(k + 1) - 1); currank >= 0; --currank)
    if (currank) {
      int iters = 0;
      while (true) {
        bool ok = true;
        for (int it = 0; it < (int)(2); ++it) {
          auto &cur = (it == 0 ? fixed : unfix);
          while (!cur.empty() && cur.rbegin()->first > currank)
            del_ver(cur.rbegin()->second);
          while (!cur.empty() && cur.rbegin()->first == currank) {
            iters++;
            del_ver(cur.rbegin()->second);
          }
          assert(cur.empty() || cur.rbegin()->first < currank);
          if (it == 1) {
            if (fixed.empty() || fixed.rbegin()->first < currank)
              ;
            ok = false;
          }
        }
        if (!ok) break;
      }
      if (iters == 0) {
        if (!unfix.empty()) {
          assert(unfix.rbegin()->first < currank);
          rk[unfix.rbegin()->second] = currank;
          del_ver(unfix.rbegin()->second);
        } else {
          cout << -1 << endl;
          return;
        }
      }
    }
  for (int i = 0; i < (int)(n); ++i) cout << rk[i] << " \n"[i + 1 == n];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  while (cin >> n) solve(n);
}
