#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
vector<int> adj[N];
int diff[N][101];
int ans[N];
int color[N];
int tot;
bool visi[N];
void dfs(int k, int n) {
  queue<int> q;
  for (int i = 1; i <= n; i++) visi[i] = 0;
  for (int i = 1; i <= n; i++)
    if (color[i] == k) diff[i][k] = 0, q.push(i);
  while (!q.empty()) {
    int src = q.front();
    q.pop();
    visi[src] = 1;
    for (int i = 0; i < adj[src].size(); i++) {
      if (visi[adj[src][i]] == 0) {
        visi[adj[src][i]] = 1;
        diff[adj[src][i]][k] = min(diff[adj[src][i]][k], diff[src][k] + 1);
        q.push(adj[src][i]);
      }
    }
  }
}
void dfs2(int s) {
  visi[s] = 1;
  for (int i = 0; i < adj[s].size(); i++) {
    for (int j = 1; j <= tot; j++) {
      if (visi[adj[s][i]] == 0)
        diff[adj[s][i]][j] = min(diff[adj[s][i]][j], diff[s][j] + 1);
    }
  }
  for (int i = 0; i < adj[s].size(); i++)
    if (visi[adj[s][i]] == 0) dfs2(adj[s][i]);
}
int main() {
  int n, m, k;
  cin >> n >> m >> tot >> k;
  for (int i = 1; i <= n; i++) cin >> color[i];
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 100; j++) diff[i][j] = N;
  }
  for (int i = 1; i <= tot; i++) dfs(i, n);
  int nn = 101;
  for (int i = 1; i <= n; i++) sort(diff[i], diff[i] + nn);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 0; j < k; j++) ans += diff[i][j];
    cout << ans << " ";
  }
}
