#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vpl = vector<pair<long long, long long>>;
using vs = vector<string>;
using pl = pair<long long, long long>;
using ll = long long int;
using vb = vector<bool>;
void read(vector<ll> &v, ll &n) {
  for (ll i = 0; i < n; ++i) cin >> v[i];
}
void print() { cout << endl; }
void write(vector<ll> &v) {
  for (ll i = 0; i < v.size(); ++i) cout << v[i] << " ";
  cout << endl;
}
void solve() {
  ll n, m, k, s, a, b;
  cin >> n >> m >> k >> s;
  vector<ll> v(n + 1);
  for (ll i = 0; i < n; ++i) {
    cin >> v[i + 1];
  }
  vector<ll> g[n + 1];
  while (m--) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vector<ll>> arr(n + 1, vector<ll>(k + 1, 0));
  vector<bool> vis(n + 1, 0);
  for (int i = 1; i <= k; i++) {
    queue<pair<ll, ll>> q;
    vector<bool> vis(n + 1, 0);
    for (int j = 1; j <= n; j++) {
      if (v[j] == i) {
        q.push({j, 0});
        vis[j] = 1;
      }
    }
    pair<ll, ll> curr;
    ll count = 0;
    while (!q.empty()) {
      curr = q.front();
      q.pop();
      arr[curr.first][i] = curr.second;
      for (auto x : g[curr.first]) {
        if (!vis[x]) {
          q.push({x, curr.second + 1});
          vis[x] = 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort((arr[i]).begin(), (arr[i]).end());
    cout << (accumulate(arr[i].begin(), arr[i].begin() + s + 1, ll(0))) << " ";
  }
  print();
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  solve();
  return 0;
}
