#include <bits/stdc++.h>
using namespace std;
int n, m, k, s;
long long int ans[100010][110];
vector<int> graph[100010];
int type[100010];
void bfs(int x) {
  queue<int> path;
  for (int i = 1; i <= n; ++i)
    if (type[i] == x) {
      path.push(i);
      ans[i][x] = 0;
    }
  while (path.size()) {
    int u = path.front();
    path.pop();
    for (int t : graph[u]) {
      if (ans[t][x] > ans[u][x] + 1) {
        ans[t][x] = ans[u][x] + 1;
        path.push(t);
      }
    }
  }
}
void init() {
  for (int i = 0; i < 100010; ++i) {
    for (int j = 0; j < 110; ++j) ans[i][j] = INT_MAX;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; ++i) cin >> type[i];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b), graph[b].push_back(a);
  }
  for (int i = 1; i <= k; ++i) bfs(i);
  for (int i = 1; i <= n; ++i) {
    vector<int> temp;
    for (int j = 1; j <= k; ++j) temp.push_back(ans[i][j]);
    sort(temp.begin(), temp.end());
    int real_ans = 0;
    for (int j = 0; j < s; ++j) real_ans += temp[j];
    cout << real_ans << " ";
  }
  return 0;
}
