#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, s, k;
  cin >> n >> m >> k >> s;
  vector<vector<int>> start(k), d(n), cst(n);
  for (int i = 0; i < n; i++) {
    int col;
    cin >> col;
    start[col - 1].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    d[u].push_back(v);
    d[v].push_back(u);
  }
  for (int kk = 0; kk < k; kk++) {
    auto q = start[kk];
    vector<int> len(n, -1);
    for (int v : q) {
      len[v] = 0;
    }
    for (int qi = 0; qi < q.size(); qi++) {
      int cur = q[qi];
      for (int v : d[cur]) {
        if (len[v] == -1) {
          len[v] = len[cur] + 1;
          q.push_back(v);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cst[i].push_back(len[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    auto vd = cst[i];
    sort(vd.begin(), vd.end());
    long long sum = 0;
    for (int i = 0; i < s; i++) {
      sum += vd[i];
    }
    cout << sum << " ";
  }
}
