#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, s, sum, el;
vector<long long int> graph[100005];
long long int vis[100005];
vector<long long int> v[105];
vector<long long int> cost[100005];
queue<long long int> q;
void bfs(long long int type) {
  long long int i;
  for (i = 0; i < v[type].size(); i++) {
    q.push(v[type][i]);
    vis[v[type][i]] = 1;
    cost[v[type][i]].push_back(0);
  }
  while (!q.empty()) {
    el = q.front();
    q.pop();
    for (auto it = graph[el].begin(); it != graph[el].end(); ++it) {
      if (vis[*it] == 0) {
        vis[*it] = 1;
        cost[*it].push_back(cost[el][type - 1] + 1);
        q.push(*it);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int a, b, num;
  cin >> n >> m >> k >> s;
  for (long long int i = 0; i < n; i++) {
    cin >> num;
    v[num].push_back(i);
  }
  for (long long int i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }
  for (long long int i = 1; i < k + 1; i++) {
    bfs(i);
    for (long long int j = 0; j < n; j++) {
      vis[j] = 0;
    }
  }
  for (long long int i = 0; i < n; i++) {
    sort(cost[i].begin(), cost[i].end());
  }
  for (long long int i = 0; i < n; i++) {
    sum = 0;
    for (long long int j = 0; j < s; j++) {
      sum += cost[i][j];
    }
    cout << sum << " ";
  }
}
