#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ll n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<ll> a(n);
  vector<vector<int>> g(n, vector<int>());
  for (ll i = 0; i < (ll)n; ++i) {
    cin >> a[i];
    a[i]--;
  }
  for (ll i = 0; i < (ll)m; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<vector<int>> res = vector<vector<int>>(n, vector<int>(k, -1));
  for (ll i = 0; i < (ll)n; ++i) {
    res[i][a[i]] = 0;
  }
  for (ll i = 0; i < (ll)k; ++i) {
    queue<int> q;
    for (ll j = 0; j < (ll)n; ++j) {
      if (a[j] == i) q.push(j);
    }
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int x = 0; x < g[cur].size(); x++) {
        if (res[g[cur][x]][i] != -1) continue;
        res[g[cur][x]][i] = res[cur][i] + 1;
        q.push(g[cur][x]);
      }
    }
  }
  for (ll i = 0; i < (ll)n; ++i) {
    sort(res[i].begin(), res[i].end());
  }
  for (ll i = 0; i < (ll)n; ++i) {
    ll cur = 0;
    for (ll j = 0; j < (ll)s; ++j) {
      cur += res[i][j];
    }
    cout << cur << " ";
  }
  cout << endl;
  return 0;
}
