Problem: There are n military men in the Berland army. Some of them have given orders to other military men by now. Given m pairs (xi, yi), meaning that the military man xi gave the i-th order to another military man yi.

It is time for reform! The Berland Ministry of Defence plans to introduce ranks in the Berland army. Each military man should be assigned a rank — integer number between 1 and k, inclusive. Some of them have been already assigned a rank, but the rest of them should get a rank soon.

Help the ministry to assign ranks to the rest of the army so that:

  * for each of m orders it is true that the rank of a person giving the order (military man xi) is strictly greater than the rank of a person receiving the order (military man yi); 
  * for each rank from 1 to k there is at least one military man with this rank. 

Input

The first line contains three integers n, m and k (1 ≤ n ≤ 2·105, 0 ≤ m ≤ 2·105, 1 ≤ k ≤ 2·105) — number of military men in the Berland army, number of orders and number of ranks.

The second line contains n integers r1, r2, ..., rn, where ri > 0 (in this case 1 ≤ ri ≤ k) means that the i-th military man has been already assigned the rank ri; ri = 0 means the i-th military man doesn't have a rank yet.

The following m lines contain orders one per line. Each order is described with a line containing two integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi). This line means that the i-th order was given by the military man xi to the military man yi. For each pair (x, y) of military men there could be several orders from x to y.

Output

Print n integers, where the i-th number is the rank of the i-th military man. If there are many solutions, print any of them.

If there is no solution, print the only number -1.

Examples

Input

5 3 3
0 3 0 0 2
2 4
3 4
3 5


Output

1 3 3 2 2 


Input

7 6 5
0 4 5 4 1 0 0
6 1
3 6
3 1
7 5
7 1
7 4


Output

2 4 5 4 1 3 5 


Input

2 2 2
2 1
1 2
2 1


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
const int maxn = 2e5 + 5;
int n, m, k;
int r[maxn];
vector<int> adj[maxn];
vector<int> radj[maxn];
vector<int> ver;
int vis[maxn];
int b[maxn];
void dfs(int u) {
  vis[u] = 1;
  for (int i = (0); i < (int((adj[u]).size())); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
      dfs(v);
    }
  }
  ver.push_back(u);
}
int num;
void rdfs(int u) {
  vis[u] = 1, num++;
  for (int i = (0); i < (int((radj[u]).size())); i++) {
    int v = radj[u][i];
    if (!vis[v]) {
      rdfs(v);
    }
  }
}
int st[maxn << 1];
void upd(int p, int val) {
  for (st[p += maxn] = 1; p > 1;) p >>= 1, st[p] = st[p << 1] + st[p << 1 | 1];
}
int query(int l, int r) {
  int res = 0;
  for (l += maxn, r += maxn + 1; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += st[l++];
    if (r & 1) res += st[--r];
  }
  return res;
}
int cmp(int u, int v) {
  if (b[u] != b[v]) {
    return b[u] < b[v];
  }
  return u < v;
}
void solve() {
  cin >> n >> m >> k;
  for (int i = (0); i < (n); i++) cin >> r[i];
  for (int i = (0); i < (m); i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    radj[v].push_back(u);
  }
  for (int i = (0); i < (n); i++)
    if (!vis[i]) dfs(i);
  fill_n(vis, n, 0);
  for (int i = (n)-1; i >= (0); i--) {
    int u = ver[i];
    if (!vis[u]) {
      num = 0, rdfs(u);
      if (num > 1) {
        cout << -1 << "\n";
        return;
      }
    }
  }
  for (int i = (0); i < (n); i++) {
    if (r[i]) {
      b[i] = r[i];
    } else {
      b[i] = k;
    }
  }
  for (int i = (n)-1; i >= (0); i--) {
    int u = ver[i];
    for (int j = (0); j < (int((adj[u]).size())); j++) {
      int v = adj[u][j];
      chkmin(b[v], b[u] - 1);
      if (b[v] <= 0) {
        cout << -1 << "\n";
        return;
      }
    }
  }
  static int f[maxn];
  static int ans[maxn];
  for (int i = (0); i < (n); i++)
    if (r[i]) {
      upd(r[i], 1);
      ans[i] = r[i];
    }
  sort((ver).begin(), (ver).end(), cmp);
  for (int i = (0); i < (n); i++) {
    int u = ver[i];
    if (!r[u]) {
      int lo = 1;
      for (int v : adj[u]) {
        chkmax(lo, ans[v] + 1);
      }
      int hi = b[u];
      while (lo < hi) {
        int mi = lo + hi >> 1;
        if (query(lo, mi) == mi - lo + 1) {
          lo = mi + 1;
        } else {
          hi = mi;
        }
      }
      int mi = lo + hi >> 1;
      ans[u] = mi;
      upd(mi, 1);
    }
  }
  for (int u = (0); u < (n); u++) {
    if (ans[u] <= 0 || ans[u] > k) {
      cout << -1 << "\n";
      return;
    }
    for (int v : adj[u]) {
      if (ans[u] <= ans[v]) {
        cout << -1 << "\n";
        return;
      }
    }
    if (r[u] && ans[u] != r[u]) {
      cout << -1 << "\n";
      return;
    }
  }
  if (query(1, k) < k) {
    cout << -1 << "\n";
    return;
  }
  for (int i = (0); i < (n); i++) cout << ans[i] << " \n"[i == n - 1];
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int JUDGE_ONLINE = 1;
  if (argc > 1) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[2], "w", stdout));
  }
  solve();
  if (!JUDGE_ONLINE) {
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  }
  return 0;
}