#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 7;
int n, m, k, s;
vector<int> gudi[N];
vector<int> adj[N], best[N];
int dist[N];
void bfs(int kind) {
  queue<int> q;
  fill(dist + 1, dist + n + 1, inf);
  for (auto u : gudi[kind]) {
    q.push(u);
    dist[u] = 0;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u]) {
      if (dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  for (int i = 1; i <= n; ++i) best[i].push_back(dist[i]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 1, x; i <= n; ++i) {
    cin >> x;
    gudi[x].push_back(i);
  }
  for (int i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= k; ++i) bfs(i);
  for (int i = 1; i <= n; ++i) {
    sort(best[i].begin(), best[i].end());
    cout << accumulate(best[i].begin(), best[i].begin() + s, 0) << ' ';
  }
  return 0;
}
