#include <bits/stdc++.h>
using namespace std;
const int INF_INT = 0x7fffffff;
const long long INF_LL = 0x7fffffffffffffff;
const long long mod = (long long)1e9 + 7;
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * f;
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    long long ret = exgcd(b, a % b, y, x);
    y -= x * (a / b);
    return ret;
  }
}
const int maxn = 200010, maxm = 11;
vector<int> edge[maxn];
int n, m, k, s;
int a[maxn], vis[maxn];
int lc[maxn][110];
void parseInput() {
  cin >> n >> m >> k >> s;
  memset(a, 0, sizeof(a));
  int tmp;
  int u, v;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
}
queue<int> q;
void bfs() {
  int u, v;
  for (int i = 1; i <= k; ++i) {
    memset(vis, 0, sizeof(vis));
    for (int j = 0; j <= n; ++j)
      if (a[j] == i) {
        q.push(j);
        lc[j][i] = 0;
        vis[j] = 1;
      }
    while (!q.empty()) {
      u = q.front();
      q.pop();
      int len = edge[u].size();
      for (int j = 0; j < len; ++j) {
        v = edge[u][j];
        if (vis[v] == 0) {
          vis[v] = 1;
          lc[v][i] = lc[u][i] + 1;
          q.push(v);
        }
      }
    }
  }
}
void solve() {
  bfs();
  for (int i = 1; i <= n; ++i) {
    sort(lc[i] + 1, lc[i] + 1 + k);
    int ans = 0;
    for (int j = 1; j <= s; ++j) ans += lc[i][j];
    cout << ans << ' ';
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  parseInput();
  solve();
  return 0;
}
