#include <bits/stdc++.h>
using namespace std;
vector<long long int> v1[100005], col[102], dis[100005];
long long int vis[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, d, s, i, j, k, sum = 0, m;
  cin >> a >> b >> k >> s;
  for (i = 1; i <= a; i++) {
    cin >> c;
    col[c].push_back(i);
  }
  for (i = 0; i < b; i++) {
    cin >> c >> d;
    v1[c].push_back(d);
    v1[d].push_back(c);
  }
  for (i = 1; i <= k; i++) {
    queue<pair<long long int, long long int> > qu;
    for (auto u : col[i]) {
      vis[u] = i;
      qu.push({u, 0});
    }
    while (!qu.empty()) {
      pair<long long int, long long int> u = qu.front();
      dis[u.first].push_back(u.second);
      qu.pop();
      for (auto v : v1[u.first]) {
        if (vis[v] == i) continue;
        vis[v] = i;
        qu.push({v, u.second + 1});
      }
    }
  }
  for (i = 1; i <= a; i++) {
    sort(dis[i].begin(), dis[i].end());
    sum = 0;
    for (j = 0; j < s; j++) sum += dis[i][j];
    cout << sum << " ";
  }
  return 0;
}
