#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long M = 33;
const long long inf = 1e16 + 7;
const long long Mod = 1e9 + 7;
const double eps = 1e-6;
int n, m, k, s;
int a[N];
int head[N], to[2 * N], nxt[2 * N], num;
int ans[N][105];
bool vis[N];
inline void Add(int u, int v) {
  nxt[++num] = head[u];
  to[num] = v;
  head[u] = num;
}
void bfs(int id) {
  queue<int> q;
  for (int i = 1; i <= n; ++i) {
    vis[i] = 0;
    if (a[i] == id) {
      vis[i] = 1;
      q.push(i);
      ans[i][id] = 0;
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int e = head[u]; e; e = nxt[e]) {
      int v = to[e];
      if (vis[v]) continue;
      vis[v] = 1;
      ans[v][id] = ans[u][id] + 1;
      q.push(v);
    }
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Add(x, y);
    Add(y, x);
  }
  for (int i = 1; i <= k; ++i) bfs(i);
  for (int i = 1; i <= n; ++i) {
    long long sum = 0;
    sort(ans[i] + 1, ans[i] + k + 1);
    for (int j = 1; j <= s; ++j) sum += ans[i][j];
    printf("%lld ", sum);
  }
  return 0;
}
