#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  int64_t n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<vector<int64_t> > o(k);
  for (int64_t i = 0; i < n; ++i) {
    int64_t a;
    cin >> a;
    o[a - 1].push_back(i);
  }
  vector<vector<int64_t> > d(n), v(n);
  for (int64_t i = 0; i < m; ++i) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int64_t i = 0; i < k; ++i) {
    queue<pair<int64_t, int64_t> > q;
    vector<char> ch(n, false);
    for (int64_t j = 0; j < o[i].size(); ++j) {
      q.push({o[i][j], 0});
      ch[o[i][j]] = true;
    }
    while (q.size()) {
      int64_t t = q.front().first, val = q.front().second;
      q.pop();
      d[t].push_back(val);
      for (int64_t j = 0; j < v[t].size(); ++j) {
        int64_t e = v[t][j];
        if (ch[e]) continue;
        ch[e] = true;
        q.push({e, val + 1});
      }
    }
  }
  for (int64_t i = 0; i < n; ++i) {
    sort(d[i].begin(), d[i].end());
    int64_t ans = 0;
    for (int64_t j = 0; j < s; ++j) ans += d[i][j];
    cout << ans << ' ';
  }
}
