#include <bits/stdc++.h>
using namespace std;
const int INF = 1e6;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<int> ind(n);
  for (auto &i : ind) cin >> i, i--;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vector<int>> d(n, vector<int>(k, INF));
  for (int i = 0; i < k; i++) {
    queue<pair<int, int>> q;
    for (int j = 0; j < n; j++) {
      if (ind[j] == i) {
        q.emplace(j, 0);
      }
    }
    while (q.size()) {
      int v = q.front().first;
      int curd = q.front().second;
      q.pop();
      if (curd >= d[v][i]) continue;
      d[v][i] = curd;
      for (int to : g[v]) {
        q.emplace(to, curd + 1);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    sort(d[i].begin(), d[i].end());
    int ans = 0;
    for (int j = 0; j < s; j++) {
      ans += d[i][j];
    }
    cout << ans << " ";
  }
}
