#include <bits/stdc++.h>
using namespace std;
struct node {
  int s, t, next;
} e[200005];
int head[100005];
int a[100005];
int dis[100005];
int vis[100005];
int g = 0;
void add(int s, int t) {
  e[g].s = s;
  e[g].t = t;
  e[g].next = head[s];
  head[s] = g++;
}
int n, m, k, s;
int bfs(int x) {
  queue<int> que;
  que.push(x);
  vis[a[x]] = a[x];
  dis[x] = 0;
  bool flag[105] = {0};
  flag[a[x]] = 1;
  int y = 1;
  int sum = 0;
  while (que.size()) {
    if (y == s) return sum;
    int u = que.front();
    que.pop();
    for (int i = head[u]; i != -1; i = e[i].next) {
      int v = e[i].t;
      if (vis[v] != x) {
        que.push(v);
        vis[v] = x;
        dis[v] = dis[u] + 1;
        if (flag[a[v]] == 0) {
          flag[a[v]] = 1;
          sum += dis[v];
          y++;
        }
        if (y == s) return sum;
      }
    }
  }
}
int main() {
  cin >> n >> m >> k >> s;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++) {
    int sum = bfs(i);
    printf("%d ", sum);
  }
  printf("\n");
}
