#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long MAXN = 100101, MAXK = 101;
long long n, m, k, s, dist[MAXN][MAXK];
vector<long long> g[MAXN], a[MAXK], c[MAXN];
bool u[MAXN];
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a[x].push_back(i);
  }
  for (long long i = 0; i < m; i++) {
    long long v1, v2;
    cin >> v1 >> v2;
    g[v1].push_back(v2);
    g[v2].push_back(v1);
  }
  for (long long i = 1; i <= k; i++) {
    for (long long j = 0; j < ((long long)(a[i]).size()); j++) {
      g[n + i].push_back(a[i][j]);
      g[a[i][j]].push_back(n + i);
    }
    for (long long j = 1; j <= n + k; j++) {
      u[j] = true;
    }
    queue<long long> q;
    q.push(n + i);
    u[n + i] = false;
    dist[n + i][i] = -1;
    while (!q.empty()) {
      long long v = q.front();
      q.pop();
      for (auto to : g[v]) {
        if (u[to] && to <= n) {
          u[to] = false;
          q.push(to);
          dist[to][i] = dist[v][i] + 1;
        }
      }
    }
    for (long long j = 1; j <= n; j++) {
      c[j].push_back(dist[j][i]);
    }
  }
  for (long long i = 1; i <= n; i++) {
    sort((c[i]).begin(), (c[i]).end());
    long long ans = 0;
    for (long long j = 0; j < s; j++) {
      ans += c[i][j];
    }
    cout << ans << " ";
  }
  return 0;
}
