#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> ms(n);
  vector<vector<int> > vex(n);
  vector<vector<int> > ses(k);
  int u, v;
  for (int i = 0; i < n; ++i) {
    cin >> ms[i];
    ms[i] -= 1;
    ses[ms[i]].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    u -= 1;
    v -= 1;
    vex[u].push_back(v);
    vex[v].push_back(u);
  }
  vector<vector<int> > D(k, vector<int>(n, 1e6));
  for (int i = 0; i < k; ++i) {
    queue<int> box;
    vector<int>& d = D[i];
    for (int& x : ses[i]) {
      box.push(x);
      d[x] = 0;
    }
    while (!box.empty()) {
      int rx = box.front();
      box.pop();
      for (int& dx : vex[rx])
        if (d[dx] == 1e6) {
          box.push(dx);
          d[dx] = d[rx] + 1;
        }
    }
  }
  vector<int> H(k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k; ++j) H[j] = D[j][i];
    sort(H.begin(), H.end());
    int mx = 0;
    for (int j = 0; j < s; ++j) mx += H[j];
    cout << mx << ' ';
  }
  return 0;
}
