#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100000;
const int KMAX = 100;
const int INF = (1 << 30);
int N, M, K, S;
int cost[NMAX + 2][KMAX + 2];
int v[NMAX + 2];
vector<int> G[NMAX + 2];
int dist[NMAX + 2];
void get_dist(int col) {
  memset(dist, 0, sizeof(dist));
  queue<int> Q;
  for (int i = 1; i <= N; ++i)
    if (v[i] == col) Q.push(i), dist[i] = 1;
  while (!Q.empty()) {
    int nod = Q.front();
    Q.pop();
    for (auto x : G[nod]) {
      if (!dist[x]) {
        dist[x] = dist[nod] + 1;
        Q.push(x);
      }
    }
  }
  for (int i = 1; i <= N; ++i) cost[i][col] = dist[i] - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> K >> S;
  for (int i = 1; i <= N; ++i) {
    cin >> v[i];
    for (int j = 0; j <= K; ++j) cost[i][j] = INF;
  }
  for (int i = 1; i <= M; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= K; ++i) get_dist(i);
  for (int i = 1; i <= N; ++i) {
    sort(cost[i] + 1, cost[i] + K + 1);
    long long best = 0;
    for (int j = 1; j <= S; ++j) best += 1LL * cost[i][j];
    cout << best << " \n"[i == N];
  }
  return 0;
}
