#include <bits/stdc++.h>
using namespace std;
int inf = INT_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> a[k];
  vector<int> g[n + 1];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x - 1].push_back(i + 1);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<vector<int>> d(n + 1, vector<int>(k, inf));
  for (int i = 0; i < k; i++) {
    queue<int> q;
    for (int c : a[i]) {
      q.push(c);
      d[c][i] = 0;
    }
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int v : g[u]) {
        if (d[v][i] == inf) {
          d[v][i] = d[u][i] + 1;
          q.push(v);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(d[i].begin(), d[i].end());
    int ans = 0;
    for (int j = 0; j < s; j++) ans += d[i][j];
    cout << ans << " ";
  }
  return 0;
}
