#include <bits/stdc++.h>
using namespace std;
vector<int> vec[100005];
int arr[100005], val[100005];
void bfs(int temp, int n) {
  deque<int> de;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == temp) {
      val[i] = 0;
      de.push_back(i);
    } else
      val[i] = 100000005;
  }
  while (!de.empty()) {
    int xx = de.front();
    de.pop_front();
    for (int i = 0; i < vec[xx].size(); i++) {
      if (val[vec[xx][i]] > val[xx] + 1) {
        val[vec[xx][i]] = val[xx] + 1;
        de.push_back(vec[xx][i]);
      }
    }
  }
}
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  vector<int> fin[100005];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i, n);
    for (int j = 1; j <= n; j++) {
      fin[j].push_back(val[j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(fin[i].begin(), fin[i].end());
    int sum = 0;
    for (int j = 0; j < s; j++) sum += fin[i][j];
    cout << sum << " ";
  }
}
