#include <bits/stdc++.h>
using namespace std;
struct point {
  int to, next;
} e[100010 << 1];
int n, m, num, K, s, cnt;
int head[100010], a[100010], b[100010], ans[100010];
bool vis[100010];
int f[100010][101];
void add(int from, int to) {
  e[++num].next = head[from];
  e[num].to = to;
  head[from] = num;
}
void dfs(int x) {
  vis[x] = true;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    for (int j = 1; j <= K; j++) f[to][j] = min(f[to][j], f[x][j] + 1);
    if (!vis[to]) dfs(to);
    for (int j = 1; j <= K; j++) f[x][j] = min(f[x][j], f[to][j] + 1);
  }
}
void check(int x) {
  vis[x] = true;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    for (int j = 1; j <= K; j++) f[to][j] = min(f[to][j], f[x][j] + 1);
    if (!vis[to]) check(to);
    for (int j = 1; j <= K; j++) f[x][j] = min(f[x][j], f[to][j] + 1);
  }
  for (int i = 1; i <= K; i++) b[i] = f[x][i];
  sort(b + 1, b + 1 + K);
  for (int i = 1; i <= s; i++) ans[x] += b[i];
}
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);
  }
  memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= n; i++) f[i][a[i]] = 0;
  while (cnt <= 2) {
    cnt++;
    memset(vis, false, sizeof(vis));
    dfs(1);
  }
  memset(vis, false, sizeof(vis));
  check(1);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
