#include <bits/stdc++.h>
using namespace std;
const int N = 100008;
int n, m, w, ww, id[N];
vector<int> a[N];
vector<int> b[N];
queue<int> d;
int vis[N], c[N][108];
int main(void) {
  int i, j, k;
  long long ss = 0;
  scanf("%d%d%d%d", &n, &m, &w, &ww);
  for (i = 1; i <= n; i++) {
    scanf("%d", id + i);
    b[id[i]].push_back(i);
  }
  while (m--) {
    scanf("%d%d", &j, &k);
    a[j].push_back(k);
    a[k].push_back(j);
  }
  for (i = 1; i <= w; i++) {
    for (j = 1; j <= n; j++) vis[j] = N;
    while (!d.empty()) d.pop();
    for (auto p : b[i]) {
      vis[p] = 0;
      d.push(p);
    }
    while (!d.empty()) {
      k = d.front();
      d.pop();
      for (auto p : a[k])
        if (vis[p] > vis[k] + 1) {
          vis[p] = vis[k] + 1;
          d.push(p);
        }
    }
    for (j = 1; j <= n; j++) c[j][i] = vis[j];
  }
  for (i = 1; i <= n; i++) sort(&c[i][1], &c[i][w + 1]);
  for (i = 1; i <= n; i++) {
    ss = 0;
    for (j = 1; j <= ww; j++) ss += c[i][j];
    printf("%I64d ", ss);
  }
  return 0;
}
