#include <bits/stdc++.h>
int n, m, k, s, goods[100001], uv[100001 * 5], Cur[100001], Nxt[100001];
bool visited[100001], mrkt[100001];
static inline int helper(int i) {
  memset(visited, 0, sizeof(visited));
  memset(mrkt, 0, sizeof(mrkt));
  Nxt[0] = i;
  int *cur = Cur, *nxt = Nxt, res = 0, goods_cnt = s, nxt_cnt = 1;
  for (int depth = 0;; depth++) {
    int *cn = cur, cur_cnt = nxt_cnt;
    cur = nxt, nxt = cn, nxt_cnt = 0;
    while (cur_cnt--) {
      int u = cur[cur_cnt];
      if (!visited[u]) {
        visited[u] = true;
        int gds = goods[u];
        if (!mrkt[gds]) {
          mrkt[gds] = true;
          res += depth;
          if (!--goods_cnt) return res;
        }
        u = uv[u];
        while (u) {
          nxt[nxt_cnt++] = uv[u + 1];
          u = uv[u];
        }
      }
    }
  }
}
int main() {
  scanf("%d %d %d %d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) scanf("%d", &goods[i]);
  int u, v, w, t = 100001;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    w = uv[u];
    uv[u] = t;
    uv[t++] = w;
    uv[t++] = v;
    w = uv[v];
    uv[v] = t;
    uv[t++] = w;
    uv[t++] = u;
  }
  for (int i = 1; i <= n; i++) printf("%d ", helper(i));
  return 0;
}
