#include <bits/stdc++.h>
using namespace std;
vector<long long int> goods[100005], v[100005], costs[100005];
long long int dist[105][100005];
bool vis[100005];
void solve() {
  long long int n, m, k, s;
  cin >> n >> m >> k >> s;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    goods[a[i]].push_back(i);
  }
  while (m--) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (long long int i = 1; i <= k; i++) {
    queue<long long int> q;
    memset(vis, false, sizeof(vis));
    for (auto j : goods[i]) {
      q.push(j);
      vis[j] = true;
    }
    while (!q.empty()) {
      long long int node = q.front();
      q.pop();
      for (auto child : v[node]) {
        if (vis[child] == false) {
          vis[child] = true;
          q.push(child);
          dist[i][child] = dist[i][node] + 1;
        }
      }
    }
    for (long long int j = 1; j <= n; j++) costs[j].push_back(dist[i][j]);
  }
  for (long long int i = 1; i <= n; i++) {
    long long int ans = 0;
    sort(costs[i].begin(), costs[i].end());
    for (long long int j = 0; j <= s - 1; j++) ans += costs[i][j];
    cout << ans << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  t = 1;
  while (t--) solve();
}
