#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int K = 100 + 10;
vector<int> G[N], P[K], ans[N];
int Q[N], dep[N];
void bfs(int x) {
  int head, tail, u, v, i;
  memset(dep, -1, sizeof(dep));
  head = tail = 0;
  for (i = 0; i < P[x].size(); i++) {
    Q[tail++] = P[x][i];
    dep[P[x][i]] = 0;
    ans[P[x][i]].push_back(0);
  }
  while (head < tail) {
    u = Q[head];
    for (i = 0; i < G[u].size(); i++) {
      v = G[u][i];
      if (dep[v] == -1) {
        Q[tail++] = v;
        dep[v] = dep[u] + 1;
        ans[v].push_back(dep[v]);
      }
    }
    head++;
  }
}
int main() {
  int res, n, m, k, s, a, u, v, i, j;
  cin >> n >> m >> k >> s;
  for (i = 1; i <= n; i++) {
    cin >> a;
    P[a].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (i = 1; i <= k; i++) bfs(i);
  for (i = 1; i <= n; i++) {
    sort(ans[i].begin(), ans[i].end());
    res = 0;
    for (j = 0; j < s; j++) res += ans[i][j];
    cout << res << " ";
  }
  return 0;
}
