#include <bits/stdc++.h>
using namespace std;
int n, m, k, s;
int a, b;
int vis[int(1e6)];
vector<int> graph[int(1e6)];
int type[int(1e6)];
queue<pair<int, int>> q;
vector<int> dist[int(1e6)];
int cost = 1;
int ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> type[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 1; i <= k; i++) {
    cost = 1;
    for (int j = 1; j <= n; j++) {
      if (type[j] == i) {
        q.push({j, 0});
        vis[j] = 1;
      }
    }
    while (!q.empty()) {
      int v = q.front().first;
      int cost = q.front().second;
      q.pop();
      for (auto u : graph[v]) {
        if (!vis[u]) {
          vis[u] = 1;
          dist[u].push_back(cost + 1);
          q.push({u, cost + 1});
        }
      }
    }
    while (!q.empty()) {
      q.pop();
    }
    for (int i = 1; i <= n; i++) {
      vis[i] = 0;
    }
    cost = 1;
  }
  for (int i = 1; i <= n; i++) {
    ans = 0;
    sort(dist[i].begin(), dist[i].end());
    for (int y = 0; y < s - 1; y++) {
      ans += dist[i][y];
    }
    cout << ans << " ";
  }
}
