#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long> pq;
int main() {
  long long n, m, k, second;
  cin >> n >> m >> k >> second;
  long long a[n + 1];
  vector<long long> pos[k + 1];
  vector<vector<long long> > adj(n + 1);
  long long dis[n + 1][k + 1];
  for (long long i = 0; i < n + 1; i++)
    for (long long j = 0; j < k + 1; j++) dis[i][j] = LLONG_MAX;
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
    dis[i][a[i]] = 0;
    pos[a[i]].push_back(i);
  }
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (long long i = 1; i < k + 1; i++) {
    queue<long long> q;
    bool vis[n + 1];
    for (long long j = 0; j < n; j++) vis[j] = 0;
    for (auto j : pos[i]) {
      q.push(j);
      vis[j] = 1;
    }
    while (!q.empty()) {
      long long u = q.front();
      q.pop();
      for (auto v : adj[u]) {
        if (dis[v][i] > dis[u][i] + 1) {
          dis[v][i] = dis[u][i] + 1;
          q.push(v);
        }
      }
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    nth_element(dis[i] + 1, dis[i] + second, dis[i] + k + 1);
    long long tmsm = 0;
    for (long long j = 1; j < second + 1; j++) tmsm += dis[i][j];
    cout << tmsm << " ";
  }
  cout << endl;
}
