#include <bits/stdc++.h>
using namespace std;
vector<int> G[1000 * 100 + 10];
int dis[1000 * 100 + 10][200], mark[1000 * 100 + 100], col[1000 * 100 + 100], n,
    m, k, s;
void BFS(int c) {
  vector<int> Q;
  for (int i = 0; i < n; i++) {
    if (col[i] == c) {
      Q.push_back(i);
      mark[i] = 1;
    } else
      mark[i] = 0;
  }
  int id = 0;
  while (id < Q.size()) {
    int u = Q[id];
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (!mark[v]) {
        dis[v][c] = dis[u][c] + 1;
        mark[v] = 1;
        Q.push_back(v);
      }
      dis[v][c] = min(dis[v][c], dis[u][c] + 1);
    }
    id++;
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 0; i < n; i++) cin >> col[i];
  while (m--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) BFS(i);
  for (int i = 0; i < n; i++) {
    sort(dis[i], dis[i] + k + 1);
    int ans = 0;
    for (int j = 1; j < s + 1; j++) ans += dis[i][j];
    cout << ans << ' ';
  }
  return 0;
}
