#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> a(n);
  vector<vector<int>> p(k);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[a[i] - 1].push_back(i);
  }
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<vector<int>> weights(n);
  for (int i = 0; i < k; i++) {
    queue<pair<int, int>> q;
    vector<bool> done(n);
    for (int j = 0; j < p[i].size(); j++) {
      done[p[i][j]] = true;
      q.push({p[i][j], 0});
      weights[p[i][j]].push_back(0);
    }
    while (q.size() > 0) {
      int ind = q.front().first;
      int weight = q.front().second;
      q.pop();
      for (int j = 0; j < adj[ind].size(); j++) {
        if (!done[adj[ind][j]]) {
          done[adj[ind][j]] = true;
          q.push({adj[ind][j], weight + 1});
          weights[adj[ind][j]].push_back(weight + 1);
        }
      }
    }
  }
  for (int i = 0; i < weights.size(); i++) {
    sort(weights[i].begin(), weights[i].end());
    int sum = 0;
    for (int j = 0; j < s; j++) {
      sum += weights[i][j];
    }
    cout << sum << " ";
  }
  cout << endl;
}
