#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> ans_now;
void bfs(vector<int> const &s) {
  queue<int> q;
  for (auto e : s) {
    ans_now[e] = 0;
    q.push(e);
  }
  while (!q.empty()) {
    auto now = q.front();
    q.pop();
    for (auto e : g[now]) {
      if (ans_now[e] == (2147483647)) {
        ans_now[e] = ans_now[now] + 1;
        q.push(e);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> kk(n);
  {
    for (auto &e : (kk)) cin >> e;
  };
  g.resize(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<int>> ans(n);
  vector<vector<int>> kkk(k);
  for (int i = 0; i < n; i++) {
    kkk[kk[i] - 1].push_back(i);
  }
  for (int i = 0; i < k; i++) {
    ans_now.assign(n, (2147483647));
    bfs(kkk[i]);
    for (int j = 0; j < n; j++) {
      ans[j].push_back(ans_now[j]);
    }
  }
  vector<int> anss(n);
  for (int i = 0; i < n; i++) {
    sort((ans[i]).begin(), (ans[i]).end());
    for (int x = 0; x < s; x++) anss[i] += ans[i][x];
  }
  for (auto e : anss) cout << e << ' ';
  return 0;
}
