#include <bits/stdc++.h>
inline int inc(int x, int v, int mod) {
  x += v;
  return x >= mod ? x - mod : x;
}
inline int dec(int x, int v, int mod) {
  x -= v;
  return x < 0 ? x + mod : x;
}
const int inf = 0x3f3f3f3f;
int _, __, ___;
using namespace std;
template <typename T>
inline void read(T& ret) {
  ret = 0;
  T f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
    c = getchar();
  }
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
long long read() {
  long long ret = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
    c = getchar();
  }
  return ret * f;
}
const int N = 100010;
int col[N], dis[N][110];
vector<int> v[N], G[N];
queue<int> q;
int main() {
  int n, m, k, s;
  read(n, m, k, s);
  for (int i = 1; i <= n; i++) col[i] = read(), v[col[i]].push_back(i);
  for (int i = 1; i <= m; i++) {
    read(_, __);
    G[_].push_back(__);
    G[__].push_back(_);
  }
  memset(dis, -1, sizeof dis);
  for (int i = 1; i <= k; i++) {
    for (auto ii : v[i]) dis[ii][i] = 0, q.push(ii);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (auto nxt : G[now]) {
        if (dis[nxt][i] == -1) {
          dis[nxt][i] = dis[now][i] + 1;
          q.push(nxt);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    sort(dis[i] + 1, dis[i] + k + 1);
    for (int j = 1; j <= s; j++) ans += dis[i][j];
    printf("%d ", ans);
  }
}
