#include <bits/stdc++.h>
using namespace std;
int w[100];
int a[1000], b[1000], ans[1000];
int deg[100][1000];
int main() {
  int i;
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (i = 0; i < n; i++) scanf("%d", &w[i]);
  for (i = 0; i < m; i++) scanf("%d %d", &a[i], &b[i]), a[i]--, b[i]--;
  int j;
  for (i = 0; i < m; i++) {
    int x, s = 1e9;
    for (j = 0; j < k; j++) {
      if (deg[a[i]][j] + deg[b[i]][j] < s)
        s = deg[a[i]][j] + deg[b[i]][j], x = j;
    }
    ans[i] = x;
    deg[a[i]][x]++, deg[b[i]][x]++;
  }
  while (1) {
    for (i = 0; i < n; i++) {
      int p = deg[i][0], q = deg[i][0];
      for (j = 0; j < k; j++) p = min(p, deg[i][j]), q = max(q, deg[i][j]);
      if (q - p > 2) break;
    }
    if (i == n) break;
    for (i = 0; i < m; i++) {
      int x = ans[i], s = deg[a[i]][ans[i]] + deg[b[i]][ans[i]];
      for (j = 0; j < k; j++) {
        if (deg[a[i]][j] + deg[b[i]][j] < s)
          s = deg[a[i]][j] + deg[b[i]][j], x = j;
      }
      deg[a[i]][ans[i]]--, deg[b[i]][ans[i]]--;
      ans[i] = x;
      deg[a[i]][x]++, deg[b[i]][x]++;
    }
  }
  for (i = 0; i < m; i++) printf("%d\n", ans[i] + 1);
  return 0;
}
