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 INF = 1e9 + 7;
const int maxn = 2e5 + 5;
int n, m, k;
int rk[maxn], vis[maxn], l[maxn], r[maxn], ans[maxn];
vector<int> ord;
vector<int> g[maxn], rg[maxn];
struct psn {
  int l, r, id;
};
bool operator<(const psn &a, const psn &b) { return (a.r > b.r); }
vector<psn> vec;
priority_queue<psn> q;
bool cmp(const psn &a, const psn &b) { return (a.l < b.l); }
void preDfs(int u) {
  vis[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (vis[v] == 1) {
      puts("-1");
      exit(0);
    } else if (!vis[v])
      preDfs(v);
  }
  vis[u] = 2;
  ord.push_back(u);
  return;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", rk + i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    rg[v].push_back(u);
  }
  for (int i = 0; i < n; i++)
    if (!vis[i]) preDfs(i);
  reverse(ord.begin(), ord.end());
  for (int i = n - 1; i >= 0; i--) {
    int mx = 0;
    int u = ord[i];
    for (int j = 0; j < g[u].size(); j++) {
      int v = g[u][j];
      mx = max(l[v], mx);
    }
    if (rk[u]) {
      if (mx + 1 > rk[u]) {
        puts("-1");
        return 0;
      }
      l[u] = rk[u];
    } else if (!g[u].size())
      l[u] = 1;
    else {
      if (mx + 1 <= 0 || mx + 1 > k) {
        puts("-1");
        return 0;
      }
      l[u] = mx + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    int mn = INF;
    int u = ord[i];
    for (int j = 0; j < rg[u].size(); j++) {
      int v = rg[u][j];
      mn = min(r[v], mn);
    }
    if (rk[u]) {
      if (mn - 1 < rk[u]) {
        puts("-1");
        return 0;
      }
      r[u] = rk[u];
    } else if (!rg[u].size())
      r[u] = k;
    else {
      if (mn - 1 <= 0 || mn - 1 > k) {
        puts("-1");
        return 0;
      }
      r[u] = mn - 1;
    }
  }
  for (int i = 0; i < n; i++) vec.push_back((psn){l[i], r[i], i});
  sort(vec.begin(), vec.end(), cmp);
  int lb = 0;
  for (int i = 1; i <= k; i++) {
    while (vec[lb].l == i) {
      q.push(vec[lb]);
      lb++;
    }
    if (q.empty()) {
      puts("-1");
      return 0;
    }
    bool ok = false;
    psn u = q.top();
    while (u.r == i) {
      ans[u.id] = i;
      q.pop();
      ok = true;
      if (q.empty()) break;
      u = q.top();
    }
    if (!ok) {
      if (q.empty()) {
        puts("-1");
        return 0;
      }
      ans[u.id] = i;
      q.pop();
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  return 0;
}