#include <bits/stdc++.h>
using namespace std;
const long long nax = 2e5 + 10;
vector<long long> g[nax], a(nax);
long long b[nax][101];
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  memset(b, -1, sizeof(b));
  long long n, m, k, p;
  cin >> n >> m >> k >> p;
  for (long long i = 1; i <= n; i++) cin >> a[i], b[i][a[i]] = 0;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 1; i <= k; i++) {
    queue<long long> q;
    for (long long j = 1; j <= n; j++)
      if (a[j] == i) q.push(j);
    while (!q.empty()) {
      auto p = q.front();
      q.pop();
      for (auto u : g[p]) {
        if (b[u][i] == -1) {
          q.push(u);
          b[u][i] = b[p][i] + 1;
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    sort(b[i] + 1, b[i] + k + 1);
    long long ans = 0;
    for (long long j = 1; j <= p; j++) ans += b[i][j];
    cout << ans << " ";
  }
}
