#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<long long> adj[n + 1];
  vector<long long> arr(n + 1, 0);
  vector<bool> visited(n + 1, false);
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<long long> ans[n + 1];
  for (long long p = 1; p <= k; p++) {
    queue<pair<long long, long long> > q;
    fill((visited).begin(), (visited).end(), false);
    for (long long i = 1; i <= n; i++) {
      if (arr[i] == p) {
        visited[i] = true;
        q.push({i, 0});
        ans[i].push_back(0);
      }
    }
    while (!q.empty()) {
      long long v = q.front().first, val = q.front().second;
      q.pop();
      for (long long u : adj[v]) {
        if (!visited[u]) {
          visited[u] = true;
          q.push({u, val + 1});
          ans[u].push_back(val + 1);
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    sort((ans[i]).begin(), (ans[i]).end());
    long long val = 0;
    for (long long j = 0; j < s; j++) val += ans[i][j];
    cout << val << " ";
  }
}
