#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;
const int MAXM = 200007;
const int MAXK = 107;
struct eT {
  void setd(int _u, int _v, int _l) { u = _u, v = _v, last = _l; }
  int u, v, last;
} edge[MAXM];
int n, m, S, K;
int a[MAXN];
int ke, la[MAXN];
int d[MAXN][MAXK];
int q[MAXN];
void init();
void input();
void work();
void bfs(int nc);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d%d%d", &n, &m, &K, &S);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int u, v;
  memset(la, -1, sizeof(la));
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    edge[ke].setd(u, v, la[u]);
    la[u] = ke++;
    edge[ke].setd(v, u, la[v]);
    la[v] = ke++;
  }
}
void work() {
  memset(d, -1, sizeof(d));
  for (int i = 1; i <= K; ++i) bfs(i);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    sort(d[i] + 1, d[i] + 1 + K);
    ans = 0;
    for (int j = 1; j <= S; ++j) ans += d[i][j];
    printf("%d ", ans);
  }
  putchar('\n');
}
void bfs(int nc) {
  int l = 0, r = 0, now, v;
  for (int i = 1; i <= n; ++i)
    if (a[i] == nc) q[r++] = i, d[i][nc] = 0;
  while (l < r) {
    now = q[l++];
    for (int i = la[now]; ~i; i = edge[i].last) {
      if (d[v = edge[i].v][nc] == -1) {
        d[v][nc] = d[now][nc] + 1;
        q[r++] = v;
      }
    }
  }
}
