#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, type[100000], dis[100000][100];
vector<int> adj[100000];
bool inQueue[100000];
void bfs(int t) {
  memset(inQueue, 0, n * sizeof(bool));
  queue<int> q;
  for (int i = 0; i < (n); i++)
    if (type[i] == t) {
      q.push(i);
      inQueue[i] = 1;
    }
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (auto next : adj[node])
      if (!inQueue[next]) {
        dis[next][t] = dis[node][t] + 1;
        q.push(next);
        inQueue[next] = 1;
      }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 0; i < (n); i++) {
    cin >> type[i];
    type[i]--;
  }
  for (int i = 0; i < (m); i++) {
    int u, v;
    cin >> u >> v;
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  for (int i = 0; i < (k); i++) bfs(i);
  for (int i = 0; i < (n); i++) {
    int res = 0;
    sort(dis[i], dis[i] + k);
    for (int j = 0; j < (s); j++) res += dis[i][j];
    cout << res << " ";
  }
}
