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 N = 200500;
int n, m, k, d[N];
struct data {
  int x, y;
} b[N];
int h[N], to[N], ne[N], tt;
void addedge(int a, int b) {
  to[++tt] = b;
  ne[tt] = h[a];
  h[a] = tt;
}
int ru[N], head, tail, op[N], mx[N], mn[N], rk[N];
int zmin, zmax;
bool flag;
void ready(int kk) {
  tt = 1;
  for (int i = 1; i <= n; i++) ru[i] = 0, h[i] = 0;
  if (kk == 0)
    for (int i = 1; i <= m; i++) addedge(b[i].x, b[i].y), ru[b[i].y]++;
  else
    for (int i = 1; i <= m; i++) addedge(b[i].y, b[i].x), ru[b[i].x]++;
  head = 1;
  tail = 0;
  for (int i = 1; i <= n; i++)
    if (!ru[i]) op[++tail] = i;
  while (head <= tail) {
    int u = op[head++];
    for (int p = h[u]; p; p = ne[p]) {
      int v = to[p];
      ru[v]--;
      if (kk == 0) {
        mx[v] = ((mx[u] - 1 < mx[v]) ? (mx[u] - 1) : (mx[v]));
        zmin = ((zmin < mx[v]) ? (zmin) : (mx[v]));
      } else {
        mn[v] = ((mn[u] + 1 > mn[v]) ? (mn[u] + 1) : (mn[v]));
        zmax = ((zmax > mn[v]) ? (zmax) : (mn[v]));
      }
      if (!ru[v]) op[++tail] = v;
    }
  }
  if (tail < n) {
    flag = 0;
    return;
  }
}
bool cmp(int A, int B) {
  return (mx[A] > mx[B] || (mx[A] == mx[B] && mn[A] > mn[B]));
}
int hp[N], hl;
bool ok(int a, int b) { return (mn[hp[a]] > mn[hp[b]]); }
void inse(int id) {
  hp[++hl] = id;
  int now = hl;
  while ((now > 1) && (ok(now, now >> 1))) {
    swap(hp[now >> 1], hp[now]);
    now >>= 1;
  }
}
void down() {
  hp[1] = hp[hl--];
  int now = 1;
  while ((now << 1) <= hl) {
    int uw;
    if ((now << 1 | 1) > hl)
      uw = now << 1;
    else
      uw = ok(now << 1, now << 1 | 1) ? (now << 1) : (now << 1 | 1);
    if (ok(uw, now))
      swap(hp[uw], hp[now]), now = uw;
    else
      break;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  flag = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  for (int i = 1; i <= m; i++) scanf("%d%d", &b[i].x, &b[i].y);
  for (int i = 1; i <= n; i++)
    if (d[i])
      mx[i] = d[i];
    else
      mx[i] = k;
  ready(0);
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (d[i])
      mn[i] = d[i];
    else
      mn[i] = 1;
  ready(1);
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (mn[i] > mx[i]) {
      flag = 0;
      break;
    }
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) rk[i] = i, d[i] = 0;
  sort(rk + 1, rk + 1 + n, cmp);
  int last = 1;
  for (int i = k; i >= 1; i--) {
    while (mx[rk[last]] == i) inse(rk[last]), last++;
    if (hl <= 0) {
      flag = 0;
      break;
    }
    int yu = hp[1];
    if (mn[yu] <= i)
      d[yu] = i;
    else {
      flag = 0;
      break;
    }
    down();
    for (; hl;) {
      yu = hp[1];
      if (mn[yu] < i) break;
      d[yu] = i;
      down();
    }
  }
  while (hl) {
    int yu = hp[1];
    if (mn[yu] <= 1)
      d[yu] = 1;
    else {
      flag = 0;
      break;
    }
    down();
  }
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) printf("%d ", d[i]);
  printf("\n");
  return 0;
}