#include <bits/stdc++.h>
using namespace std;
mt19937 dadi(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 100 + 5, K = 1e3 + 5;
int n, m, k, w[N], p[K], cnt[N][K];
struct game {
  int u, v, t;
} a[K];
inline int add(int u, int v) {
  shuffle(p, p + k, dadi);
  int mx1 = *max_element(cnt[u], cnt[u] + k);
  int mx2 = *max_element(cnt[v], cnt[v] + k);
  for (int i = 0; i < k; i++)
    if (cnt[u][p[i]] < mx1 && cnt[v][p[i]] < mx2) return p[i];
  for (int i = 0; i < k; i++)
    if (cnt[u][p[i]] < mx1 || cnt[v][p[i]] < mx2) return p[i];
  return p[0];
}
inline void read_input() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < m; i++) {
    cin >> a[i].u >> a[i].v;
    a[i].u--, a[i].v--;
  }
}
inline void solve() {
  for (iota(p, p + k, 0); true; memset(cnt, 0, sizeof cnt)) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      cnt[a[i].u][a[i].t = add(a[i].u, a[i].v)]++;
      cnt[a[i].v][a[i].t++]++;
    }
    for (int i = 0; i < n; i++)
      flag &=
          *max_element(cnt[i], cnt[i] + k) - *min_element(cnt[i], cnt[i] + k) <
          3;
    if (flag) break;
  }
}
inline void write_output() {
  for (int i = 0; i < m; i++) cout << a[i].t << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}
