#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1E6;
inline void fastio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
signed main() {
  fastio();
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) {
    long long x;
    cin >> x;
    a[i] = --x;
  }
  vector<vector<long long> > g(n, vector<long long>()),
      r(n, vector<long long>(k, 0));
  vector<long long> v(n, 0);
  for (long long i = (0); i < (m); i++) {
    long long x, y;
    cin >> x >> y;
    g[--x].push_back(--y);
    g[y].push_back(x);
  }
  for (long long i = (0); i < (k); i++) {
    queue<long long> q;
    for (long long j = (0); j < (n); j++) {
      if (a[j] == i) {
        q.push(j);
        r[j][i] = 0;
        v[j] = 1;
      }
    }
    while (!q.empty()) {
      long long x = q.front();
      q.pop();
      for (auto &j : g[x]) {
        if (v[j]) continue;
        v[j] = 1;
        r[j][i] = r[x][i] + 1;
        q.push(j);
      }
    }
    v = vector<long long>(n, 0);
  }
  for (long long i = (0); i < (n); i++) {
    sort(r[i].begin(), r[i].end());
    long long ans = 0;
    for (long long j = (0); j < (s); j++) ans += r[i][j];
    cout << ans << " ";
  }
}
