#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
vector<long long> v[N];
vector<long long> vcol[105];
vector<long long> dis[N];
void bfs(long long x, long long* d) {
  queue<long long> q;
  d[x] = 1;
  q.push(x);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (int y : v[x])
      if (!d[y]) {
        d[y] = d[x] + 1;
        q.push(y);
      }
  }
}
void solve() {
  long long n, m = 0, i = 1, j = 0, l = 0, r = 0;
  long long sum = 0, y = 0, q, z = 0, ans = 0, x, k = 0;
  cin >> n >> m >> k >> x;
  for (i = 1; i <= n; i++) {
    cin >> j;
    vcol[j].push_back(i);
  }
  for (i = 0; i < m; i++) {
    cin >> l >> r;
    v[l].push_back(r);
    v[r].push_back(l);
  }
  for (int col = 1; col <= k; col++) {
    long long d[N] = {};
    for (long long i : vcol[col]) {
      v[0].push_back(i);
      v[i].push_back(0);
    }
    bfs(0, d);
    for (i = 1; i <= n; i++)
      if (d[i] >= 2) dis[i].push_back(d[i] - 2);
    v[0].clear();
    for (long long i : vcol[col]) v[i].pop_back();
  }
  for (i = 1; i <= n; i++) sort(dis[i].begin(), dis[i].end());
  for (i = 1; i <= n; i++) {
    ans = 0;
    for (j = 0; j < x; j++) {
      ans += dis[i][j];
    }
    cout << ans << " ";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int T = 1;
  while (T--) solve();
  return 0;
}
