#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> G[maxn];
int n, m, k, s, a[maxn], vis[maxn], dis[maxn][105];
queue<int> q;
void bfs() {
  for (int j = 1; j <= k; j++) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++)
      if (a[i] == j) q.push(i), dis[i][j] = 0, vis[i] = 1;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (vis[v] == 0) {
          dis[v][j] = dis[u][j] + 1;
          vis[v] = 1;
          q.push(v);
        }
      }
    }
  }
}
int main() {
  int x, y;
  while (cin >> n >> m >> k >> s) {
    for (int i = 0; i <= n; i++) G[i].clear();
    for (int i = 1; i <= n; i++) cin >> a[i];
    while (m--) {
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    bfs();
    for (int i = 1; i <= n; i++) {
      sort(dis[i] + 1, dis[i] + 1 + k);
      int ans = 0;
      for (int j = 1; j <= s; j++) ans += dis[i][j];
      cout << ans << " ";
    }
    cout << endl;
  }
  return 0;
}
