#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int d[105][N], n, m, k, s, a[N];
vector<int> pos[N], g[N];
void bfs(int id) {
  queue<int> q;
  for (auto v : pos[id]) d[id][v] = 0, q.push(v);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (d[id][v] > d[id][u] + 1) {
        d[id][v] = d[id][u] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = (1); i < (n + 1); i++) cin >> a[i], pos[a[i]].push_back(i);
  int u, v;
  for (int i = (1); i < (m + 1); i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  memset(d, 0x3f, sizeof(d));
  for (int i = (1); i < (k + 1); i++) bfs(i);
  vector<int> pp;
  for (int i = (1); i < (n + 1); i++) {
    pp.clear();
    for (int j = (1); j < (k + 1); j++) {
      pp.push_back(d[j][i]);
    }
    sort(pp.begin(), pp.end());
    int ans = 0;
    for (int j = (0); j < (s); j++) ans += pp[j];
    cout << ans << " ";
  }
  return 0;
}
