Problem: There are n football teams in the world. 

The Main Football Organization (MFO) wants to host at most m games. MFO wants the i-th game to be played between the teams a_i and b_i in one of the k stadiums. 

Let s_{ij} be the numbers of games the i-th team played in the j-th stadium. MFO does not want a team to have much more games in one stadium than in the others. Therefore, for each team i, the absolute difference between the maximum and minimum among s_{i1}, s_{i2}, …, s_{ik} should not exceed 2.

Each team has w_i — the amount of money MFO will earn for each game of the i-th team. If the i-th team plays l games, MFO will earn w_i ⋅ l.

MFO needs to find what games in what stadiums they need to host in order to earn as much money as possible, not violating the rule they set.

However, this problem is too complicated for MFO. Therefore, they are asking you to help them.

Input

The first line contains three integers n, m, k (3 ≤ n ≤ 100, 0 ≤ m ≤ 1 000, 1 ≤ k ≤ 1 000) — the number of teams, the number of games, and the number of stadiums.

The second line contains n integers w_1, w_2, …, w_n (1 ≤ w_i ≤ 1 000) — the amount of money MFO will earn for each game of the i-th game.

Each of the following m lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i) — the teams that can play the i-th game. It is guaranteed that each pair of teams can play at most one game.

Output

For each game in the same order, print t_i (1 ≤ t_i ≤ k) — the number of the stadium, in which a_i and b_i will play the game. If the i-th game should not be played, t_i should be equal to 0.

If there are multiple answers, print any.

Example

Input


7 11 3
4 7 8 10 10 9 3
6 2
6 1
7 6
4 3
4 6
3 1
5 3
7 5
7 3
4 2
1 4


Output


3
2
1
1
3
1
2
1
2
3
2

Note

One of possible solutions to the example is shown below:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int rd() {
  int rx = 0, fx = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') fx = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) {
    rx = rx * 10 + c - 48;
    c = getchar();
  }
  return rx * fx;
}
const int N = 2050, M = 2e4 + 50;
int n, m, K, cnt = 1, tim = 0;
int col[M], vis[M], F[N], G[N], s[2];
int he[N], nh[N][2];
struct Edge {
  int v, id, nxt;
} e[M];
void eadd(int u, int v, int i) {
  cnt++;
  e[cnt].v = v;
  e[cnt].id = i;
  e[cnt].nxt = he[u];
  he[u] = cnt;
  cnt++;
  e[cnt].v = u;
  e[cnt].id = i;
  e[cnt].nxt = he[v];
  he[v] = cnt;
}
void query(int u, int *f) {
  int i;
  for (i = 0; i <= K; i++) f[i] = 0;
  for (i = he[u]; i; i = e[i].nxt) {
    f[col[e[i].id]]++;
  }
  f[0] = f[1];
  for (i = 2; i <= K; i++) f[0] = min(f[0], f[i]);
}
void dfs(int u, int c) {
  int v;
  for (int &i = nh[u][c]; i; i = e[i].nxt) {
    if (vis[e[i].id] == tim) continue;
    if (col[e[i].id] == s[c]) {
      col[e[i].id] = s[c ^ 1];
      vis[e[i].id] = tim;
      v = e[i].v;
      i = e[i].nxt;
      dfs(v, c ^ 1);
      return;
    }
  }
}
int main() {
  int i, j, u, v;
  n = rd();
  m = rd();
  K = rd();
  if (K == 1) {
    while (m--) puts("1");
    return 0;
  }
  for (i = 1; i <= n; i++) rd();
  for (i = 1; i <= m; i++) {
    tim = i;
    u = rd();
    v = rd();
    query(u, F);
    query(v, G);
    for (j = 1; j <= K; j++) {
      if (F[j] < F[0] + 2 && G[j] < G[0] + 2) {
        col[i] = j;
        break;
      }
    }
    if (col[i] == 0) {
      for (s[0] = 1; F[s[0]] != F[0]; s[0]++)
        ;
      for (s[1] = 1; G[s[1]] != G[0]; s[1]++)
        ;
      col[i] = s[1];
      for (j = 1; j <= n; j++) nh[j][0] = nh[j][1] = he[j];
      dfs(u, 1);
    }
    eadd(u, v, i);
  }
  for (i = 1; i <= m; i++) printf("%d\n", col[i]);
  return 0;
}