#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
const int MAXK = 105;
int n, m, s, k;
int a[MAXN];
std::vector<int> g[MAXN];
int d[MAXN];
int ans[MAXN][MAXK];
void bfs(int type) {
  std::queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (a[i] == type) {
      q.push(i);
      d[i] = 0;
    } else {
      d[i] = -1;
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : g[x]) {
      if (d[y] == -1) {
        d[y] = d[x] + 1;
        q.push(y);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ans[i][type] = d[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 a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i);
  }
  static int Ans[MAXN];
  for (int i = 1; i <= n; i++) {
    std::sort(ans[i] + 1, ans[i] + k + 1);
    for (int j = 1; j <= s; j++) {
      Ans[i] += ans[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", Ans[i], " \n"[i == n]);
  }
  return 0;
}
