#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e4 + 10;
long long rd() {
  long long x = 0, first = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') first = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * first;
}
int main() {
  int n = rd(), m = rd(), k = rd(), second = rd();
  vector<int> a(n);
  for (int i = 0; i <= n - 1; i++) a[i] = rd() - 1;
  vector<vector<int> > g(n);
  for (int i = 0; i <= m - 1; i++) {
    int x = rd() - 1, y = rd() - 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<int> > dist(k, vector<int>(n, -1));
  for (int type = 0; type <= k - 1; type++) {
    vector<int> que;
    for (int i = 0; i <= n - 1; i++) {
      if (a[i] == type) {
        dist[type][i] = 0;
        que.push_back(i);
      }
    }
    for (int b = 0; b <= que.size() - 1; b++) {
      for (int u : g[que[b]]) {
        if (dist[type][u] == -1) {
          dist[type][u] = dist[type][que[b]] + 1;
          que.push_back(u);
        }
      }
    }
  }
  vector<int> d(k);
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= k - 1; j++) d[j] = dist[j][i];
    sort((d).begin(), (d).end());
    long long sum = 0;
    for (int j = 0; j <= second - 1; j++) sum += d[j];
    printf("%d ", sum);
  }
  puts("");
}
