#include <bits/stdc++.h>
using namespace std;
vector<int> a[100005];
vector<int> kind[105];
int dist[100005][101];
queue<int> q;
int check[100005];
int GN;
void bfs(int f) {
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (int i = 0; i < a[node].size(); i++) {
      int next = a[node][i];
      if (check[next] != GN) {
        check[next] = GN;
        dist[next][f] = dist[node][f] + 1;
        q.push(next);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    kind[x].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  memset(dist, 0x3f3f3f3f, sizeof(dist));
  for (int i = 1; i <= k; i++) {
    GN++;
    for (auto x : kind[i]) {
      dist[x][i] = 0;
      check[x] = GN;
      q.push(x);
    }
    bfs(i);
  }
  for (int i = 1; i <= n; i++) {
    sort(dist[i] + 1, dist[i] + 1 + k);
    int ans = 0;
    for (int j = 1; j <= s; j++) {
      ans += dist[i][j];
    }
    cout << ans << " ";
  }
  return 0;
}
