#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, next;
} edge[200005];
int tol, head[100005];
int du[100005];
void init() {
  tol = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int u, int v) {
  edge[tol].to = v;
  edge[tol].next = head[u];
  head[u] = tol++;
  edge[tol].to = u;
  edge[tol].next = head[v];
  head[v] = tol++;
}
int n, m, k, s, x, y;
int a[100005];
int visit[100005], cl[100005];
struct lol {
  int pl, ii;
} l[100005];
long long int bfs(int i, int kk) {
  int l_cur = 0, l_end = 1;
  long long int sum = 0;
  int cur_cl = 1;
  l[0].pl = 0;
  l[0].ii = i;
  cl[a[i]] = kk;
  visit[i] = kk;
  if (cur_cl == s) return sum;
  while (l_cur != l_end) {
    int cur_i = l[l_cur].ii;
    int cur_pl = l[l_cur].pl;
    for (int e = head[cur_i]; e != -1; e = edge[e].next) {
      int to = edge[e].to;
      if (visit[to] != kk) {
        visit[to] = kk;
        l[l_end].pl = cur_pl + 1;
        l[l_end++].ii = to;
        if (cl[a[to]] != kk) {
          sum += cur_pl + 1;
          cl[a[to]] = kk;
          cur_cl++;
          if (cur_cl == s) return sum;
        }
      }
    }
    l_cur++;
  }
}
int main() {
  init();
  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++) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
  }
  memset(visit, 0, sizeof(visit));
  memset(cl, 0, sizeof(cl));
  for (int i = 1; i <= n; i++) {
    printf("%I64d ", bfs(i, i));
  }
  printf("\n");
  return 0;
}
