#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
#pragma GCC Optimize("Ofast")
vector<long long> q[maxn];
long long h[maxn];
bool vis[maxn];
vector<long long> v[maxn];
vector<long long> gd[maxn];
int main() {
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    q[x].push_back(i);
  }
  for (int i = 0; i < int(m); i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= k; i++) {
    memset(vis, 0, sizeof vis);
    memset(h, 0, sizeof h);
    queue<long long> Q = (queue<long long>());
    for (int j = 0; j < int((q[i]).size()); j++) {
      vis[q[i][j]] = 1;
      Q.push(q[i][j]);
    }
    while ((Q).size()) {
      long long t = Q.front();
      Q.pop();
      gd[t].push_back(h[t]);
      for (int j = 0; j < int((v[t]).size()); j++) {
        long long y = v[t][j];
        if (!vis[y]) {
          vis[y] = 1;
          h[y] = h[t] + 1;
          Q.push(y);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(gd[i].begin(), gd[i].end());
    long long ans = 0;
    for (int j = 0; j < int(s); j++) {
      ans += gd[i][j];
    }
    cout << ans << " ";
  }
}
