#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
void solve() {
  long long int n, m, k, s;
  rd(n, m, k, s);
  map<long long int, long long int> color;
  map<long long int, vector<long long int>> group;
  for (long long int i = 0; i < n; i++) {
    long long int t;
    cin >> t;
    group[t].push_back(i + 1);
    color[i + 1] = t;
  }
  vector<long long int> adj[n + 1];
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    rd(u, v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<vector<long long int>> dis(n + 1, vector<long long int>(k + 1, -1));
  for (auto type : group) {
    long long int C = type.first;
    queue<long long int> q;
    for (auto node : type.second) {
      q.push(node);
      dis[node][C] = 0;
    }
    while (q.size()) {
      long long int node = q.front();
      q.pop();
      for (auto child : adj[node]) {
        if (dis[child][C] == -1) {
          dis[child][C] = dis[node][C] + 1;
          q.push(child);
        }
      }
    }
  }
  for (__typeof(n + 1) i = (1) - ((1) > (n + 1));
       i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {
    sort(dis[i].begin(), dis[i].end());
    long long int sum = 0;
    for (__typeof(s + 1) j = (1) - ((1) > (s + 1));
         j != (s + 1) - ((1) > (s + 1)); j += 1 - 2 * ((1) > (s + 1)))
      sum += dis[i][j];
    cout << sum << " ";
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
