#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> a(n);
  vector<vector<int>> color(k);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    color[a[i]].push_back(i);
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<vector<int>> nearest(n);
  for (int i = 0; i < k; i++) {
    queue<int> q;
    vector<int> d(n, INF);
    for (int v : color[i]) {
      q.push(v);
      d[v] = 0;
    }
    while (q.size()) {
      int v = q.front();
      q.pop();
      for (int to : g[v]) {
        if (d[to] > d[v] + 1) {
          d[to] = d[v] + 1;
          q.push(to);
        }
      }
    }
    for (int j = 0; j < n; j++) {
      nearest[j].push_back(d[j]);
    }
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    sort(nearest[i].begin(), nearest[i].end());
    for (int j = 0; j < s; j++) {
      cnt += nearest[i][j];
    }
    cout << cnt << " ";
  }
  return 0;
}
