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;
const int N = 410, K = 5e3 + 10;
struct Edge {
  int u, v;
  long long cap, flow;
  int id;
  Edge() {}
  Edge(int u, int v, long long cap, int id)
      : u(u), v(v), cap(cap), flow(0), id(id) {}
};
struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;
  Dinic(int N) : N(N), E(0), g(N), d(N), pt(N) {}
  void AddEdge(int u, int v, long long cap, int id) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap, id));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0, -1));
      g[v].emplace_back(E.size() - 1);
    }
  }
  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (u == T) break;
      for (int k : g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }
  long long DFS(int u, int T, long long flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i] ^ 1];
      if (d[e.v] == d[e.u] + 1) {
        long long amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (long long pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }
  long long MaxFlow(int S, int T) {
    long long total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (long long flow = DFS(S, T)) total += flow;
    }
    return total;
  }
};
int deg[N], lo[N], hi[N], w[N];
int u[K], v[K], type[K];
bool used[K];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, t;
  cin >> n >> k >> t;
  int m = n;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
  }
  for (int i = 1; i <= k; ++i) {
    cin >> u[i] >> v[i];
    ans += w[u[i]] + w[v[i]];
    v[i] += n;
    ++deg[u[i]];
    ++deg[v[i]];
  }
  for (int c = 1; c <= t; ++c) {
    int source = 0, sink = n + m + 1;
    int dummy_source = n + m + 2, dummy_sink = n + m + 3;
    Dinic dinic(n + m + 4);
    memset(deg, 0, sizeof(deg));
    for (int i = 1; i <= k; ++i) {
      if (!used[i]) {
        dinic.AddEdge(u[i], v[i], 1, i);
        ++deg[u[i]];
        ++deg[v[i]];
      }
    }
    int cur_t = (t - c + 1);
    int sum_lhs = 0, sum_rhs = 0, inf = 0;
    for (int i = 1; i <= n; ++i) {
      lo[i] = deg[i] / cur_t;
      hi[i] = (deg[i] + cur_t - 1) / cur_t;
      dinic.AddEdge(dummy_source, i, hi[i] - lo[i], -1);
      dinic.AddEdge(source, i, lo[i], -1);
      sum_lhs += lo[i];
      inf += hi[i];
    }
    for (int i = n + 1; i <= n + m; ++i) {
      lo[i] = deg[i] / cur_t;
      hi[i] = (deg[i] + cur_t - 1) / cur_t;
      dinic.AddEdge(i, dummy_sink, hi[i] - lo[i], -1);
      dinic.AddEdge(i, sink, lo[i], -1);
      sum_rhs += lo[i];
    }
    dinic.AddEdge(source, dummy_sink, sum_rhs, -1);
    dinic.AddEdge(dummy_sink, dummy_source, inf, -1);
    dinic.AddEdge(dummy_source, sink, sum_lhs, -1);
    assert(dinic.MaxFlow(source, sink) == sum_lhs + sum_rhs);
    for (auto &e : dinic.E) {
      if (e.id != -1 and e.flow) {
        type[e.id] = c;
        used[e.id] = true;
      }
    }
  }
  for (int i = 1; i <= k; ++i) {
    cout << type[i] << '\n';
  }
}