#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, K = 105;
int n, m, k, s, head[N], xnt, dis[N][K], a[N], q[K][N], h, t[K];
struct Ed {
  int next, to;
  Ed(int n = 0, int t = 0) : next(n), to(t) {}
} ed[N << 1];
void add(int x, int y) {
  ed[++xnt] = Ed(head[x], y);
  head[x] = xnt;
  ed[++xnt] = Ed(head[y], x);
  head[y] = xnt;
}
int main() {
  cin >> n >> m >> k >> s;
  memset(dis, 0x3f, sizeof dis);
  int i;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    dis[i][a[i]] = 0;
    q[a[i]][++t[a[i]]] = i;
  }
  int x, y;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    add(x, y);
  }
  for (i = 1; i <= k; i++) {
    h = 1;
    while (h <= t[i]) {
      int k = q[i][h++];
      for (int j = head[k], v; j; j = ed[j].next)
        if (dis[v = ed[j].to][i] > dis[k][i] + 1) {
          dis[v][i] = dis[k][i] + 1;
          q[i][++t[i]] = v;
        }
    }
  }
  for (i = 1; i <= n; i++) {
    int ans = 0;
    sort(dis[i] + 1, dis[i] + k + 1);
    for (int j = 1; j <= s; j++) ans += dis[i][j];
    cout << ans << " ";
  }
  return 0;
}
