#include <bits/stdc++.h>
using namespace std;
int dis[100001][101];
int vis[100001][101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(dis, -1, sizeof(dis));
  int n, m, k, s1;
  cin >> n >> m >> k >> s1;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<int> adj[n + 1];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  queue<pair<int, int>> q;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[j] == i) q.push({j, 0});
    }
    while (!q.empty()) {
      int curr = q.front().first;
      int curr_d = q.front().second;
      q.pop();
      if (dis[curr][i] != -1) continue;
      dis[curr][i] = curr_d;
      for (int j = 0; j < adj[curr].size(); j++) {
        int child = adj[curr][j];
        if (dis[child][i] == -1) {
          q.push({child, curr_d + 1});
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    sort(dis[i] + 1, dis[i] + k + 1);
    for (int j = 1; j <= s1; j++) ans += dis[i][j];
    cout << ans << " ";
  }
  cout << endl;
}
