#include <bits/stdc++.h>
using namespace std;
long long dist[100005][105];
long long a[100005];
vector<long long> v[100005];
long long vis[100005];
long long n, m, k, s;
void solve() {
  cin >> n >> m >> k >> s;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < k; j++) dist[i][j] = INT_MAX;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (long long i = 0; i < k; i++) {
    vector<long long> q;
    for (long long j = 0; j < n; j++) {
      if (a[j] == i) {
        dist[j][i] = 0;
        q.push_back(j);
      }
    }
    for (long long j = 0; j < q.size(); j++) {
      for (long long u : v[q[j]]) {
        if (dist[u][i] == INT_MAX) {
          dist[u][i] = dist[q[j]][i] + 1;
          q.push_back(u);
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    sort(dist[i], dist[i] + k);
    long long sum = 0;
    for (long long j = 0; j < s; j++) sum += dist[i][j];
    cout << sum << " ";
  }
}
int32_t main() {
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
