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;
struct bian {
  int nxt, to, id;
} bi[2020], bi1[6060];
int n, m, k, w[110], c[1010], b[1010][2], head[110], num, cnt[1010], head1[110],
    num1, d[110];
bool vis[110], used[3030];
int st[3030], tp;
inline void add(int from, int to) {
  bi[++num] = bian{head[from], to};
  head[from] = num;
}
inline void add1(int from, int to, int id) {
  bi1[++num1] = bian{head1[from], to, id};
  head1[from] = num1;
  ++d[to];
}
void dfs(int v) {
  vis[v] = 1;
  for (int i = head1[v], u; i; i = bi1[i].nxt) {
    u = bi1[i].to;
    if (!vis[u]) dfs(u);
  }
}
void dfs1(int v, int fb) {
  for (int &i = head1[v], u; i; i = bi1[i].nxt)
    if (!used[(i + 1) / 2]) {
      used[(i + 1) / 2] = 1;
      u = bi1[i].to;
      dfs1(u, bi1[i].id);
    }
  st[++tp] = fb;
}
void recolor(int c1, int c2) {
  memset(head1, 0, n + 1 << 2);
  num1 = 0;
  memset(d, 0, n + 1 << 2);
  memset(vis, 0, n + 1);
  for (int i = 1; i <= m; ++i)
    if (c[i] == c1 || c[i] == c2)
      add1(b[i][0], b[i][1], i), add1(b[i][1], b[i][0], i);
  for (int i = 1; i <= n; ++i)
    if (d[i] & 1) {
      add1(0, i, 0);
      add1(i, 0, 0);
      if (!vis[i]) dfs(i);
    }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      dfs(i);
      add1(0, i, 0), add1(i, 0, 0);
      add1(0, i, 0), add1(i, 0, 0);
    }
  memset(used + 1, 0, num1 / 2);
  dfs1(0, 0);
  while (tp) c[st[tp]] = tp & 1 ? c1 : c2, --tp;
  for (int i = 1; i <= num1 / 2; ++i) assert(used[i]);
}
int main() {
  srand(time(0) + (unsigned long long)(new char));
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  int x, y;
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &x, &y);
    add(x, y), add(y, x);
    c[i] = rand() % k + 1;
    b[i][0] = x, b[i][1] = y;
  }
  while (1) {
    bool ok = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = head[i]; j; j = bi[j].nxt) ++cnt[c[(j + 1) / 2]];
      int mi = 1, mx = 1, cmx, cmi;
      for (int j = 2; j <= k; ++j) {
        if (cnt[j] > cnt[mx]) mx = j;
        if (cnt[j] < cnt[mi]) mi = j;
      }
      cmx = cnt[mx], cmi = cnt[mi];
      for (int j = head[i]; j; j = bi[j].nxt) --cnt[c[(j + 1) / 2]];
      if (cmx - cmi > 2) ok = 0, recolor(mi, mx);
    }
    if (ok) break;
  }
  for (int i = 1; i <= m; ++i) printf("%d\n", c[i]);
  return 0;
}