#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int mod = 998244353;
int n, m, k, s, a[N];
vector<int> g[N];
int qs, qt, q[N];
int d[N], w[N];
int tmr;
vector<int> e[N];
vector<int> co[N];
inline void go(int col) {
  qs = qt = 0;
  ++tmr;
  for (int v : e[col]) {
    q[qt++] = v;
    w[v] = tmr;
    d[v] = 0;
  }
  while (qs < qt) {
    int v = q[qs++];
    co[v].push_back(d[v]);
    for (int to : g[v]) {
      if (w[to] != tmr) {
        w[to] = tmr;
        q[qt++] = to;
        d[to] = d[v] + 1;
      }
    }
  }
}
inline int solve(int st) {
  nth_element(co[st].begin(), co[st].begin() + s, co[st].end());
  int ans = 0;
  for (int i = 0; i < s; ++i) ans += co[st][i];
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    e[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= k; ++i) {
    go(i);
  }
  for (int i = 1; i <= n; ++i) {
    cout << solve(i) << ' ';
  }
  return 0;
}
