#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, maxk = 105, maxe = 200005;
int n, m, K, S, a[maxn], f[maxn][maxk], INF = 1e9;
int fir[maxn], nxt[maxe], son[maxe], tot;
int q[maxn];
void add(int x, int y) {
  son[++tot] = y;
  nxt[tot] = fir[x];
  fir[x] = tot;
}
void Solve(int p) {
  for (int i = 1; i <= n; i++) f[i][p] = INF;
  q[0] = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] == p) q[++q[0]] = i, f[i][p] = 0;
  for (int i = 1; i <= q[0]; i++) {
    int x = q[i];
    for (int j = fir[x]; j; j = nxt[j])
      if (f[son[j]][p] == INF) f[son[j]][p] = f[x][p] + 1, q[++q[0]] = son[j];
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &K, &S);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= K; i++) Solve(i);
  for (int i = 1; i <= n; i++) {
    sort(f[i] + 1, f[i] + 1 + K);
    long long ans = 0;
    for (int j = 1; j <= S; j++) ans += f[i][j];
    printf("%lld ", ans);
  }
  return 0;
}
