#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long SZ = 1e5 + 5;
const long long mod = 1e9 + 7;
long long n, m, k, s;
long long a[SZ];
long long dis[SZ][102];
bool vis[SZ][102];
vector<long long> adj[SZ], gd[102];
void bfs(long long id) {
  queue<long long> q;
  for (auto v : gd[id]) {
    q.push(v);
    vis[v][id] = 1;
  }
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto v : adj[u]) {
      if (vis[v][id]) continue;
      vis[v][id] = 1;
      dis[v][id] = dis[u][id] + 1;
      q.push(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long cs = 0, tc = 1, x, y, z, i, j, g, p, q, ans = 0, sum = 0, c = 0,
            t = 0;
  string s1, s2;
  cin >> n >> m >> k >> s;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    gd[a[i]].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (i = 1; i <= k; i++) {
    bfs(i);
  }
  for (i = 1; i <= n; i++) {
    c = 0;
    sort(dis[i] + 1, dis[i] + k + 1);
    for (j = 1; j <= s; j++) c += dis[i][j];
    cout << c << " ";
  }
  cout << "\n";
  return 0;
}
