#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005, MAX_K = 105;
int N, M, K, S;
int good_type[MAX_N];
int distances[MAX_N][MAX_K];
vector<int> adj[MAX_N];
int dist[MAX_N];
void RunBFS(int type) {
  queue<int> q;
  for (int i = 0; i < N; ++i) {
    if (good_type[i] == type) {
      distances[i][type] = 0;
      q.push(i);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (const int& v : adj[u]) {
      if (distances[v][type] == -1) {
        distances[v][type] = distances[u][type] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  scanf("%d %d %d %d", &N, &M, &K, &S);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &good_type[i]);
    --good_type[i];
  }
  for (int i = 0; i < M; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(distances, -1, sizeof distances);
  for (int i = 0; i < K; ++i) {
    RunBFS(i);
  }
  for (int i = 0; i < N; ++i) {
    sort(distances[i], distances[i] + K);
    long long sum = 0;
    for (int j = 0; j < S; ++j) sum += distances[i][j];
    printf("%lld ", sum);
  }
  return 0;
}
