#include <bits/stdc++.h>
using namespace std;
int n, m, k, s;
int ms[100005][105];
vector<int> edge[100005], color[100005];
void bfs() {
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) ms[j][i] = -1;
    queue<int> q;
    vector<int>::iterator at = color[i].begin();
    for (; at != color[i].end(); at++) {
      ms[*at][i] = 0;
      q.push(*at);
    }
    while (!q.empty()) {
      int a = q.front();
      q.pop();
      at = edge[a].begin();
      for (; at != edge[a].end(); at++)
        if (ms[*at][i] == -1) {
          ms[*at][i] = ms[a][i] + 1;
          q.push(*at);
        }
    }
  }
}
int main() {
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;
    color[tmp].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    sort(ms[i] + 1, ms[i] + k + 1);
    int sum = 0;
    for (int j = 1; j <= s; j++) {
      sum += ms[i][j];
    }
    cout << sum << ' ';
  }
}
