#include <bits/stdc++.h>
using namespace std;
int n, m, s, k, a[100005];
vector<int> g[100005], edge[100005];
int dis[100005][102];
int main() {
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    g[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  memset(dis, -1, sizeof(dis));
  for (int b = 1; b <= k; b++) {
    queue<int> q;
    for (int i = 0; i < g[b].size(); i++) {
      q.push(g[b][i]);
      dis[g[b][i]][b] = 0;
    }
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < edge[x].size(); i++) {
        if (dis[edge[x][i]][b] == -1) {
          dis[edge[x][i]][b] = dis[x][b] + 1;
          q.push(edge[x][i]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    sort(dis[i] + 1, dis[i] + 1 + k);
    for (int j = 1; j <= s; j++) ans += dis[i][j];
    cout << ans << " ";
  }
}
