#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<vector<int>> edges(n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    edges[u].push_back(v);
    edges[v].push_back(u);
  };
  vector<vector<int>> val(n);
  for (int l = 1; l <= k; ++l) {
    vector<int> visited(n, -1);
    deque<int> queue;
    for (int i = 0; i < n; ++i)
      if (a[i] == l) {
        visited[i] = 0;
        queue.push_back(i);
        val[i].push_back(0);
      };
    while (queue.size()) {
      auto u = queue.front();
      queue.pop_front();
      int d = visited[u];
      for (auto v : edges[u])
        if (visited[v] == -1) {
          visited[v] = d + 1;
          val[v].push_back(d + 1);
          queue.push_back(v);
        };
    };
  };
  for (int i = 0; i < n; ++i) {
    sort(val[i].begin(), val[i].end());
    long long sum = 0;
    for (int j = 0; j < s; ++j) sum += val[i][j];
    cout << sum << " ";
  };
  cout << endl;
};
