#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
bool per(long double a, long double b) {
  return a > (long double)(1LL << 62) / b;
}
long double fastpow(long double x, long long b) {
  if (b == 0) return 1;
  if (b & 1) {
    long double y = fastpow(x, b - 1);
    if (y == -1) return -1;
    if (per(x, y)) return -1;
    return x * y;
  }
  long double t = fastpow(x, b / 2);
  if (t == -1) return -1;
  return (per(t, t) ? -1 : t * t);
}
long double log(long double base, long double x) {
  return std::log(x) / std::log(base);
}
const int maxn = 1e5 + 20;
vector<int> r[maxn];
int d[maxn][110];
void solve() {
  int n, m, k, second;
  cin >> n >> m >> k >> second;
  int a[n];
  vector<int> b[k];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[a[i] - 1].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    r[a].push_back(b);
    r[b].push_back(a);
  }
  for (int i = 0; i < k; ++i) {
    queue<int> q;
    int dist[n];
    for (int j = 0; j < n; ++j) dist[j] = maxn;
    for (auto &j : b[i]) {
      q.push(j);
      dist[j] = 0;
    }
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto &u : r[v]) {
        if (dist[v] + 1 < dist[u]) {
          dist[u] = dist[v] + 1;
          d[u][i] = dist[v] + 1;
          q.push(u);
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    vector<int> v;
    for (int j = 0; j < k; ++j) v.push_back(d[i][j]);
    sort(v.begin(), v.end());
    int ans = 0;
    for (int j = 0; j < second; ++j) ans += v[j];
    cout << ans << ' ';
  }
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
