#include <bits/stdc++.h>
using namespace std;
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
int N, M, K;
vector<int> W;
vector<pair<int, int> > A;
vector<int> B;
const int MAXN = 105;
const int MAXK = 1005;
int C[MAXN][MAXK];
int P[MAXK];
int add(int a, int b) {
  shuffle(P, P + K, mt);
  int m1, m2;
  m1 = C[a][0];
  m2 = C[b][0];
  for (int i = 0; i < K; ++i) {
    m1 = max(m1, C[a][i]);
    m2 = max(m2, C[b][i]);
  }
  for (int i = 0; i < K; ++i)
    if (C[a][P[i]] < m1 && C[b][P[i]] < m2) return P[i];
  for (int i = 0; i < K; ++i)
    if (C[a][P[i]] < m1 || C[b][P[i]] < m2) return P[i];
  return P[0];
}
void wow() {
  for (int i = 0; i < K; ++i) P[i] = i;
  while (true) {
    memset(C, 0, sizeof(C));
    for (int i = 0; i < M; ++i) {
      B[i] = add(A[i].first, A[i].second);
      C[A[i].first][B[i]]++;
      C[A[i].second][B[i]]++;
    }
    bool okay = true;
    for (int i = 0; i < N; ++i) {
      int m1, m2;
      m1 = m2 = C[i][0];
      for (int j = 1; j < K; ++j) {
        m1 = min(m1, C[i][j]);
        m2 = max(m2, C[i][j]);
      }
      if (m2 - m1 > 2) okay = false;
    }
    if (okay) break;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> K;
  W.resize(N);
  for (int i = 0; i < N; ++i) cin >> W[i];
  A.resize(M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    A[i].first = a;
    A[i].second = b;
  }
  B.resize(M);
  wow();
  for (int i = 0; i < M; ++i) cout << B[i] + 1 << endl;
  return 0;
}
