#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> Graph[N];
queue<int> q;
int a[N];
int dist[N][105];
vector<int> visited;
void bfs(int k, int n) {
  visited.resize(N);
  for (int i = 1; i <= n; i++) {
    if (a[i] == k) {
      q.push(i);
      dist[i][k] = 0;
      visited[i] = 1;
    }
  }
  while (!q.empty()) {
    int pp = q.front();
    q.pop();
    for (int i = 0; i < Graph[pp].size(); i++) {
      int v = Graph[pp][i];
      if (!visited[v]) {
        visited[v] = 1;
        dist[v][k] = dist[pp][k] + 1;
        q.push(v);
      }
    }
  }
  visited.clear();
}
int main() {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    Graph[u].push_back(v);
    Graph[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i, n);
  }
  bfs(1, n);
  for (int i = 1; i <= n; i++) {
    sort(dist[i] + 1, dist[i] + k + 1);
    int ans = 0;
    for (int j = 1; j <= s; j++) {
      ans += dist[i][j];
    }
    cout << ans << " ";
  }
}
