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;
int N, M, K;
int R[200005];
vector<int> G[200005], GT[200005];
int Ord[200005], cnt, Pos[200005];
bool Used[200005], Used2[200005];
bool Fixed[200005];
int Cnt[200005];
set<pair<int, int> > Neighb[200005];
set<pair<int, int> > S;
vector<int> X[200005];
vector<int> V[200005];
void Read() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; i++) scanf("%d", &R[i]);
  for (int i = 1; i <= M; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    GT[y].push_back(x);
  }
}
void DFS(int node) {
  Used[node] = true;
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    if (Used[neighb]) continue;
    DFS(neighb);
  }
  Ord[++cnt] = node;
}
void precalcPos() {
  reverse(Ord + 1, Ord + N + 1);
  for (int i = 1; i <= N; i++) {
    Pos[Ord[i]] = i;
  }
}
bool checkDag() {
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      int neighb = G[i][j];
      if (Pos[i] > Pos[neighb]) return false;
    }
  }
  return true;
}
bool precalcRMax() {
  for (int i = 1; i <= N; i++) {
    int node = Ord[i];
    if (R[node] != 0) {
      Cnt[R[node]]++;
      Fixed[node] = 1;
      continue;
    }
    R[node] = K;
    for (int j = 0; j < GT[node].size(); j++) {
      int neighb = GT[node][j];
      R[node] = min(R[node], R[neighb] - 1);
    }
    if (R[node] <= 0) {
      return false;
    }
    Cnt[R[node]]++;
    V[R[node]].push_back(node);
  }
  return true;
}
set<pair<int, int> >::iterator prev(set<pair<int, int> >::iterator it) {
  --it;
  return it;
}
void precalcX() {
  for (int i = 1; i <= N; i++) {
    if (Fixed[i]) continue;
    for (int j = 0; j < G[i].size(); j++) {
      Neighb[i].insert(make_pair(R[G[i][j]], G[i][j]));
    }
  }
  for (int i = 1; i <= N; i++) {
    if (Fixed[i]) continue;
    int val;
    if (Neighb[i].size() == 0) {
      val = 1;
    } else
      val = prev(Neighb[i].end())->first + 1;
    X[val].push_back(i);
  }
}
bool distribute() {
  int left = 1, right = 0;
  while (left <= K) {
    for (int i = 0; i < X[left].size(); i++) {
      if (Used2[X[left][i]]) continue;
      S.insert(make_pair(R[X[left][i]], X[left][i]));
    }
    if (Cnt[left] > 0) {
      ++left;
      continue;
    }
    while (S.size() > 0) {
      if (R[S.begin()->second] <= left)
        S.erase(S.begin());
      else
        break;
    }
    if (S.size() == 0) {
      return false;
    }
    int node = S.begin()->second;
    Used2[node] = 1;
    for (int i = 0; i < GT[node].size(); i++) {
      int neighb = GT[node][i];
      if (Fixed[neighb]) continue;
      Neighb[neighb].erase(make_pair(R[node], node));
      Neighb[neighb].insert(make_pair(left, node));
      int val = prev(Neighb[neighb].end())->first + 1;
      X[val].push_back(neighb);
    }
    Cnt[R[node]]--;
    R[node] = left;
    S.erase(S.begin());
    ++left;
  }
  return true;
}
bool check() {
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      int neighb = G[i][j];
      if (R[i] <= R[neighb]) return false;
    }
  }
  return true;
}
void Print() {
  for (int i = 1; i <= N; i++) {
    printf("%d ", R[i]);
  }
  printf("\n");
}
int main() {
  Read();
  for (int i = 1; i <= N; i++) {
    if (!Used[i]) DFS(i);
  }
  precalcPos();
  if (!checkDag()) {
    printf("-1\n");
    return 0;
  }
  if (!precalcRMax()) {
    printf("-1\n");
    return 0;
  }
  precalcX();
  if (!distribute()) {
    printf("-1\n");
    return 0;
  }
  if (!check()) {
    printf("-1\n");
    return 0;
  }
  Print();
  return 0;
}