#include <bits/stdc++.h>
using namespace std;
struct wf {
  int to, nxt;
} edge[100005 << 1];
int h[100005], cnt, n, m, s, k, a[100005];
int vis[100005];
int dis[100005][105];
queue<int> Q;
void add(int u, int v) {
  edge[++cnt].to = v;
  edge[cnt].nxt = h[u];
  h[u] = cnt;
}
void BFS(int nw) {
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = h[u]; i; i = edge[i].nxt) {
      int v = edge[i].to;
      if (vis[v]) continue;
      Q.push(v);
      vis[v] = 1;
      dis[v][nw] = dis[u][nw] + 1;
    }
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= k; i++) {
    memset(vis, 0, sizeof(vis));
    for (int j = 1; j <= n; j++)
      if (a[j] == i) Q.push(j), vis[j] = 1;
    BFS(i);
  }
  int num;
  for (int i = 1; i <= n; i++) {
    num = 0;
    sort(dis[i] + 1, dis[i] + k + 1);
    for (int j = 1; j <= s; j++) num += dis[i][j];
    printf("%d ", num);
  }
  return 0;
}
