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>
int n, m, k, intial;
const int oo = INT_MAX;
class Node {
 public:
  bool lock = false, check = false;
  int bac_vao = 0, u = oo, d, key;
  std::vector<int> e, p;
  void operator=(Node& b) {
    int x = this->u;
    this->u = b.u;
    b.u = x;
    x = this->d;
    this->d = b.d;
    b.d = x;
    x = this->key;
    this->key = b.key;
    b.key = x;
  }
};
Node a[1000001];
bool checked[1000001];
std::vector<int> stack, btrack;
void Swap(Node& a, Node& b) {
  Node c = a;
  a = b;
  b = c;
}
void Fail() {
  std::cout << -1;
  exit(EXIT_SUCCESS);
}
void Breakdown() {
  int x;
  while (stack.size() > 0) {
    x = stack[stack.size() - 1];
    if (a[x].u <= 1) return;
    intial += 1;
    stack.pop_back();
    for (int i = 0; i < a[x].e.size(); ++i) {
      if (a[a[x].e[i]].lock && a[x].u - 1 < a[a[x].e[i]].u) return;
      a[a[x].e[i]].u = std::min(a[a[x].e[i]].u, a[x].u - 1);
      if (--a[a[x].e[i]].bac_vao == 0) stack.push_back(a[x].e[i]);
      if (a[a[x].e[i]].e.size() == 0 && !a[a[x].e[i]].check) {
        btrack.push_back(a[x].e[i]);
        a[a[x].e[i]].check = true;
        a[a[x].e[i]].d = std::max(a[a[x].e[i]].d, 0);
      }
    }
    if (!a[x].check && a[x].e.size() == 0) {
      btrack.push_back(x);
      a[x].check = true;
      a[x].d = std::max(a[x].d, 0);
    }
  }
}
void Breakup() {
  int x;
  while (btrack.size() > 0) {
    x = btrack[btrack.size() - 1];
    btrack.pop_back();
    for (int i = 0; i < a[x].p.size(); ++i) {
      a[a[x].p[i]].e.pop_back();
      a[a[x].p[i]].d = std::max(a[a[x].p[i]].d, a[x].d + 1);
      if (a[a[x].p[i]].e.size() == 0) btrack.push_back(a[x].p[i]);
    }
  }
}
void qsort(int l, int r) {
  int s(l), e(r), u(a[(l + r) / 2].u), d(a[(l + r) / 2].d);
  while (s <= e) {
    while (a[s].d < d || (a[s].d == d && a[s].u < u)) ++s;
    while (d < a[e].d || (a[e].d == d && u < a[e].u)) --e;
    if (s <= e) Swap(a[s++], a[e--]);
  }
  if (l < e) qsort(l, e);
  if (s < r) qsort(s, r);
}
int ans[1000001];
int heap[1000001], hsize;
void Swap(int& a, int& b) {
  int c = a;
  a = b;
  b = c;
}
void Downheap() {
  int i = 1, x;
  while (i * 2 <= hsize) {
    x = i * 2;
    if (x < hsize && a[heap[x]].u > a[heap[x + 1]].u) ++x;
    if (a[heap[x]].u < a[heap[i]].u)
      Swap(heap[x], heap[i]);
    else
      return;
    i = x;
  }
}
void Upheap() {
  int i = hsize;
  while (i > 1) {
    if (a[heap[i]].u < a[heap[i / 2]].u)
      Swap(heap[i], heap[i / 2]);
    else
      return;
    i /= 2;
  }
}
void Solve() {
  heap[++hsize] = 1;
  int s = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i].d > a[i - 1].d)
      while (s <= a[i].d) {
        if (hsize == 0) Fail();
        if (a[heap[1]].u > s)
          ans[a[heap[1]].key] = s++;
        else
          ans[a[heap[1]].key] = a[heap[1]].u - 1;
        Swap(heap[1], heap[hsize--]);
        Downheap();
      }
    heap[++hsize] = i;
    Upheap();
  }
  while (s <= k || hsize > 0) {
    if (hsize == 0) Fail();
    if (a[heap[1]].u > s)
      ans[a[heap[1]].key] = s++;
    else
      ans[a[heap[1]].key] = a[heap[1]].u - 1;
    Swap(heap[1], heap[hsize--]);
    Downheap();
    if (s > k && hsize > 0) s = k;
  }
}
int main() {
  std::cin >> n >> m >> k;
  int s1, s2;
  for (int i = 1; i <= n; i++) {
    std::cin >> s1;
    if (s1 > 0) {
      a[i].u = s1 + 1;
      a[i].d = s1 - 1;
      a[i].lock = true;
    } else
      a[i].u = k + 1;
  }
  for (int i = 0; i < m; ++i) {
    std::cin >> s1 >> s2;
    a[s1].e.push_back(s2);
    a[s2].p.push_back(s1);
    ++a[s2].bac_vao;
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i].bac_vao == 0) {
      stack.push_back(i);
      if (!a[i].lock) a[i].u = k + 1;
    }
    a[i].key = i;
  }
  Breakdown();
  if (intial < n) Fail();
  Breakup();
  qsort(1, n);
  Solve();
  for (int i = 1; i <= n; i++) std::cout << ans[i] << ' ';
}