#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, r;
bool dd[100005];
int dist[100005][105];
vector<int> a[100005], type[100005];
queue<int> t1, t2;
void reset() {
  while (!t1.empty()) t1.pop();
  while (!t2.empty()) t2.pop();
  for (int i = 1; i <= n; i++) dd[i] = 0;
  r = 0;
}
void go(int i, int x) {
  dist[i][x] = r;
  for (auto u : a[i]) {
    if (dd[u] == 0) {
      dd[u] = 1;
      t2.push(u);
    }
  }
}
void bfs(int x) {
  for (auto u : type[x]) {
    t1.push(u);
    dd[u] = 1;
  }
  while (!t1.empty() || !t2.empty()) {
    while (!t1.empty()) {
      go(t1.front(), x);
      t1.pop();
    }
    r++;
    t2.swap(t1);
  }
}
int main() {
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    type[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);
  }
  for (int i = 1; i <= k; i++) {
    reset();
    bfs(i);
  }
  for (int i = 1; i <= n; i++) {
    int cost = 0;
    sort(dist[i] + 1, dist[i] + k + 1);
    for (int j = 1; j <= s; j++) cost += dist[i][j];
    cout << cost << " ";
  }
}
