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;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
string direc = "URDL";
const long long MOD2 = (long long)1000000007 * (long long)1000000007;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
class MinCostFlow {
 public:
  int S, T, ecnt;
  int head[300];
  int flw[3000], cost[3000], dis[300];
  int to[3000], next[3000];
  bool use[300];
  MinCostFlow() {
    memset(head, 0, sizeof(head));
    ecnt = 2;
  }
  void add_edge(int u, int v, int _c, int ww) {
    flw[ecnt] = _c;
    cost[ecnt] = ww;
    to[ecnt] = v;
    next[ecnt] = head[u];
    head[u] = ecnt++;
    flw[ecnt] = 0;
    cost[ecnt] = -ww;
    to[ecnt] = u;
    next[ecnt] = head[v];
    head[v] = ecnt++;
    assert(ecnt < 3000);
  }
  void SPFA() {
    for (int i = 1; i <= T; ++i) dis[i] = (1 << 29);
    priority_queue<pair<int, int> > Q;
    dis[S] = 0;
    Q.push(make_pair(0, S));
    while (!Q.empty()) {
      int u = Q.top().second, d = -Q.top().first;
      Q.pop();
      if (dis[u] != d) continue;
      for (int p = head[u]; p; p = next[p]) {
        int &v = to[p];
        if (flw[p] && dis[v] > d + cost[p]) {
          dis[v] = d + cost[p];
          Q.push(make_pair(-dis[v], v));
        }
      }
    }
    for (int i = 1; i <= T; ++i) dis[i] = dis[T] - dis[i];
  }
  int add_flow(int u, int flow, int &minCost) {
    if (u == T) {
      minCost += dis[S] * flow;
      return flow;
    }
    use[u] = true;
    int now = flow;
    for (int p = head[u]; p; p = next[p]) {
      int &v = to[p];
      if (flw[p] && !use[v] && dis[u] == dis[v] + cost[p]) {
        int tmp = add_flow(v, min(now, flw[p]), minCost);
        flw[p] -= tmp;
        flw[p ^ 1] += tmp;
        now -= tmp;
        if (!now) break;
      }
    }
    return flow - now;
  }
  bool modify_label() {
    int d = (1 << 29);
    for (int u = 1; u <= T; ++u)
      if (use[u])
        for (int p = head[u]; p; p = next[p]) {
          int &v = to[p];
          if (flw[p] && !use[v]) d = min(d, dis[v] + cost[p] - dis[u]);
        }
    if (d == (1 << 29)) return false;
    for (int i = 1; i <= T; ++i)
      if (use[i]) dis[i] += d;
    return true;
  }
  pair<int, int> minCostFlow(int s, int t) {
    S = s;
    T = t;
    SPFA();
    int flw = 0;
    int minCost = 0;
    while (true) {
      while (true) {
        for (int i = 1; i <= T; ++i) use[i] = 0;
        int tt = add_flow(S, (1 << 29), minCost);
        flw += tt;
        if (!tt) break;
      }
      if (!modify_label()) break;
    }
    return {flw, minCost};
  }
  vector<pair<int, int> > getEdge() {
    vector<pair<int, int> > ans;
    for (int(i) = 1; (i) <= (int)(T); (i)++)
      for (int j = head[i]; j > 0; j = next[j])
        if (flw[j] == 0) {
          ans.push_back(make_pair(i, to[j]));
        }
    return ans;
  }
};
int w[1035], u[1035], v[1035], ans[1035], dgl[1035], dgr[1035];
void fmain(int tid) {
  scanf("%d%d%d", &n, &m, &k);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", w + i);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d", u + i, v + i);
    if (v[i] < u[i]) swap(u[i], v[i]);
    dgl[u[i]]++;
    dgr[v[i]]++;
  }
  for (int t = k; t; t--) {
    MinCostFlow mf = MinCostFlow();
    int S = 1, T = n + n + 2;
    for (int(j) = 1; (j) <= (int)(m); (j)++)
      if (ans[j] == 0) {
        mf.add_edge(u[j] + 1, v[j] + n + 1, 1, 0);
      }
    for (int(i) = 1; (i) <= (int)(n); (i)++) {
      mf.add_edge(1, i + 1, dgl[i] / t, 0);
      mf.add_edge(i + 1 + n, T, dgr[i] / t, 0);
      if (dgl[i] % t != 0) mf.add_edge(S, i + 1, 1, 1);
      if (dgr[i] % t != 0) mf.add_edge(i + 1 + n, T, 1, 1);
    }
    mf.minCostFlow(S, T);
    for (int j = 1, z = 3; j <= m; j++)
      if (ans[j] == 0) {
        if (mf.flw[z] == 1) {
          ans[j] = t;
          dgl[u[j]]--;
          dgr[v[j]]--;
        }
        z += 2;
      }
  }
  for (int(j) = 1; (j) <= (int)(m); (j)++) printf("%d ", ans[j]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}