#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
int nTowns, nRoads, nGoods, lowerBound;
int main() {
  cin >> nTowns >> nRoads >> nGoods >> lowerBound;
  deque<int> groups[nGoods];
  vector<int> graph[nTowns];
  int dist[nTowns][nGoods];
  for (int i = 0; i < nTowns; ++i)
    for (int j = 0; j < nGoods; ++j) dist[i][j] = INF;
  for (int i = 0; i < nTowns; ++i) {
    int good;
    cin >> good;
    --good;
    groups[good].push_back(i);
    dist[i][good] = 0;
  }
  int u, v;
  for (int i = 0; i < nRoads; ++i) {
    cin >> u >> v;
    --u;
    --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int g = 0; g < nGoods; ++g) {
    deque<int>& frontier = groups[g];
    int curDist = 1;
    while (!frontier.empty()) {
      const int size = frontier.size();
      for (int i = 0; i < size; ++i) {
        int node = frontier.front();
        frontier.pop_front();
        for (int neighbor : graph[node]) {
          if (dist[neighbor][g] == INF) {
            dist[neighbor][g] = curDist;
            frontier.push_back(neighbor);
          }
        }
      }
      ++curDist;
    }
  }
  for (int i = 0; i < nTowns; ++i) {
    sort(dist[i], dist[i] + nGoods);
    long long sum = 0;
    for (int j = 0; j < lowerBound; ++j) sum += dist[i][j];
    cout << sum << " ";
  }
  cout << endl;
  return 0;
}
