#include <bits/stdc++.h>
using namespace std;
int n, m, s, k;
int dist[100010][101], w[100010];
queue<int> q;
vector<int> ga[100010];
void bfs(int id) {
  for (int i = 1; i <= n; i++)
    if (w[i] == id) {
      dist[i][id] = 0;
      q.push(i);
    }
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = 0; i < ga[cur].size(); i++) {
      if (dist[ga[cur][i]][id] == -1) {
        q.push(ga[cur][i]);
        dist[ga[cur][i]][id] = dist[cur][id] + 1;
      }
    }
  }
}
int main() {
  cin >> n >> m >> k >> s;
  memset(dist, -1, sizeof(dist));
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    ga[a].push_back(b);
    ga[b].push_back(a);
  }
  for (int i = 1; i <= k; i++) bfs(i);
  for (int i = 1; i <= n; i++) {
    sort(dist[i] + 1, dist[i] + k + 1);
    int sum = 0;
    for (int j = 1; j <= s; j++) sum += dist[i][j];
    cout << sum << ' ';
  }
  return 0;
}
