#include <bits/stdc++.h>
using namespace std;
int n, m, k, s;
int a[100100], dist[101][100100], cur_dist[101];
vector<vector<int>> g;
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    --a[i];
  }
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int from, to;
    scanf("%d%d", &from, &to);
    --from;
    --to;
    g[from].push_back(to);
    g[to].push_back(from);
  }
  for (int t = 0; t < k; ++t) {
    memset(dist[t], -1, sizeof dist[t]);
    queue<int> q;
    for (int i = 0; i < n; ++i) {
      if (a[i] == t) {
        dist[t][i] = 0;
        q.push(i);
      }
    }
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int to : g[v]) {
        if (dist[t][to] != -1) {
          continue;
        }
        dist[t][to] = dist[t][v] + 1;
        q.push(to);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int t = 0; t < k; ++t) {
      cur_dist[t] = dist[t][i];
    }
    sort(cur_dist, cur_dist + k);
    int sum = 0;
    for (int i = 0; i < s; ++i) {
      sum += cur_dist[i];
    }
    printf("%d ", sum);
  }
  printf("\n");
  return 0;
}
