#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
const int maxn = 1000100;
int n, m, k;
int tab[maxn];
int s;
vector<long long> best[maxn];
long long d[maxn];
vector<int> v[maxn];
long long dp[maxn];
void bfs(int col) {
  queue<int> q;
  for (int i = (1); i <= (n); ++i)
    if (tab[i] == col) {
      q.push(i);
      d[i] = 0;
    } else
      d[i] = INF;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto u : v[x])
      if (d[u] == INF) {
        d[u] = d[x] + 1;
        q.push(u);
      }
  }
  for (int i = (1); i <= (n); ++i) best[i].push_back(d[i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k >> s;
  for (int i = (1); i <= (n); ++i) cin >> tab[i];
  for (int i = (1); i <= (m); ++i) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = (1); i <= (k); ++i) bfs(i);
  for (int i = (1); i <= (n); ++i) {
    sort(best[i].begin(), best[i].end());
    long long res = 0;
    for (int j = 0; j < s; ++j) res += best[i][j];
    cout << res << ' ';
  }
}
