#include <bits/stdc++.h>
using namespace std;
int N, M, K, L, Q;
int A[110001];
int dist[110001][101];
bool visit[110001];
vector<int> G[110001];
const int GV = 100100;
void Solve(int which) {
  queue<pair<int, int> > q;
  q.push({GV + which, -1});
  for (int i = 0; i < 110001; i++) visit[i] = 0;
  visit[GV + which] = 1;
  while (!q.empty()) {
    auto cur = q.front();
    q.pop();
    int n = cur.first;
    for (int i = 0; i < G[n].size(); i++) {
      int next = G[n][i];
      if (visit[next]) continue;
      visit[next] = 1;
      dist[next][which] = cur.second + 1;
      q.push({next, cur.second + 1});
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M >> K >> L;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < N; i++) {
    G[GV + A[i]].push_back(i);
  }
  for (int i = 0; i < K; i++) Solve(i);
  for (int i = 0; i < N; i++) {
    vector<int> rret;
    for (int j = 0; j < K; j++) rret.push_back(dist[i][j]);
    sort(rret.begin(), rret.end());
    int ret = 0;
    for (int j = 0; j < L; j++) ret += rret[j];
    cout << ret << " ";
  }
  cin >> N;
}
