#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, INF = 2 * 1e9 + 1;
int n, m, k, s, a[maxn], level[maxn];
vector<int> graph[maxn], vis[maxn];
priority_queue<int> pq[maxn];
void multi_bfs(int c) {
  memset(level, 0, sizeof level);
  ;
  queue<int> Q;
  for (int x : vis[c]) {
    level[x] = 1;
    Q.push(x);
  }
  while (!Q.empty()) {
    int top = Q.front();
    Q.pop();
    pq[top].push(-(level[top] - 1));
    for (int nb : graph[top]) {
      if (!level[nb]) {
        level[nb] = level[top] + 1;
        Q.push(nb);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    vis[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int c = 1; c <= k; c++) {
    multi_bfs(c);
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0, cnt = 1;
    while (cnt <= s) {
      int t = pq[i].top();
      ans += -t;
      pq[i].pop();
      cnt++;
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
