#include <bits/stdc++.h>
using namespace std;
const int maxn = 101010;
bool mark[maxn];
queue<int> q;
vector<int> vec[maxn];
int n, m, k, s, cur, arr[maxn], dist[maxn][101];
void bfs() {
  int u;
  for (int i = 1; i <= n; ++i) {
    if (arr[i] == cur) dist[i][cur] = 0, q.push(i), mark[i] = true;
  }
  while (!q.empty()) {
    u = q.front(), q.pop();
    for (int i = 0; i < vec[u].size(); ++i) {
      if (!mark[vec[u][i]])
        dist[vec[u][i]][cur] = dist[u][cur] + 1, q.push(vec[u][i]),
        mark[vec[u][i]] = true;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  int u, v;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  for (int i = 1; i <= k; ++i) {
    memset(mark, false, sizeof(mark));
    cur = i, bfs();
  }
  for (int i = 1; i <= n; ++i) sort(dist[i], dist[i] + k + 1);
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= s; ++j) ans += dist[i][j];
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
