#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
const long long MOD = 1e9 + 7;
int N, M, S, K;
int a[100100];
vector<int> cmp[100100];
bool seen[100100];
vector<int> g[100100];
int cl[100100][111];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M >> K >> S;
  memset(cl, 0x3f, sizeof cl);
  for (int i = 1; i <= N; i++)
    cin >> a[i], cl[i][a[i]] = 0, cmp[a[i]].push_back(i);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int c = 1; c <= K; c++) {
    memset(seen, 0, sizeof seen);
    queue<int> q;
    for (int v : cmp[c]) cl[v][c] = 0, q.push(v), seen[v] = 1;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int w : g[v]) {
        if (seen[w]) continue;
        cl[w][c] = cl[v][c] + 1;
        seen[w] = 1;
        q.push(w);
      }
    }
  }
  for (int v = 1; v <= N; v++) {
    sort(cl[v] + 1, cl[v] + K + 1);
    long long res = 0;
    for (int i = 1; i <= S; i++) res += cl[v][i];
    cout << res << " \n"[v == N];
  }
  return 0;
}
