#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100002];
bool vis[102][100002];
int dis[102][100002];
queue<int> q;
void bfs(vector<int> &S, int tp) {
  for (int i : S) {
    q.push(i);
    dis[tp][i] = 0;
    vis[tp][i] = true;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : adj[u]) {
      if (vis[tp][v]) continue;
      vis[tp][v] = true;
      dis[tp][v] = dis[tp][u] + 1;
      q.push(v);
    }
  }
}
vector<int> T[102];
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    T[val].push_back(i + 1);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) {
    bfs(T[i], i);
  }
  for (int i = 1; i <= n; i++) {
    vector<int> C;
    for (int j = 1; j <= k; j++) {
      C.push_back(dis[j][i]);
    }
    sort(C.begin(), C.end());
    int ans = 0;
    for (int j = 0; j < s; j++) {
      ans += C[j];
    }
    cout << ans << " ";
  }
  cout << endl;
}
