#include <bits/stdc++.h>
using namespace std;
int a[100005], was[100005], q[100001][101], n, m, k, s;
vector<vector<int> > neigh(100005);
void solve(int x) {
  deque<int> cur;
  for (int i = 1; i <= n; i++)
    if (a[i] == x) {
      cur.push_back(i);
      was[i] = 1;
      q[i][x] = 0;
    }
  while (cur.size() > 0) {
    int now = cur[0];
    cur.pop_front();
    for (int i = 0; i < neigh[now].size(); i++)
      if (!was[neigh[now][i]]) {
        q[neigh[now][i]][x] = q[now][x] + 1;
        was[neigh[now][i]] = 1;
        cur.push_back(neigh[now][i]);
      }
  }
}
int main() {
  int i, j;
  cin >> n >> m >> k >> s;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) {
    int z, x;
    cin >> z >> x;
    neigh[z].push_back(x);
    neigh[x].push_back(z);
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= k; j++) q[i][j] = 9e8;
  for (i = 1; i <= k; i++) {
    solve(i);
    for (j = 1; j <= n; j++) was[j] = 0;
  }
  for (i = 1; i <= n; i++) {
    sort(q[i] + 1, q[i] + 1 + k);
    int ans = 0;
    for (j = 1; j <= s; j++) ans += q[i][j];
    cout << ans << " ";
  }
  return 0;
}
