#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, t, u, v, cnt, cost;
int a[100002], vis[100002], tp[102], dis[100002];
vector<int> tu[100002];
void bfs(int x) {
  dis[x] = 0;
  cnt = 1;
  cost = 0;
  queue<int> q;
  memset(tp, 0, sizeof(tp));
  tp[a[x]] = 1;
  memset(vis, 0, sizeof(vis));
  q.push(x);
  vis[x] = 1;
  while (!q.empty()) {
    if (cnt == s) return;
    t = q.front();
    q.pop();
    for (int i = 0; i < tu[t].size(); i++) {
      if (vis[tu[t][i]]) continue;
      q.push(tu[t][i]);
      dis[tu[t][i]] = dis[t] + 1;
      vis[tu[t][i]] = 1;
    }
    if (!tp[a[t]]) {
      tp[a[t]] = 1;
      cost += dis[t];
      cnt++;
    }
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int j = 1; j <= m; j++) {
    scanf("%d%d", &u, &v);
    tu[u].push_back(v);
    tu[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    bfs(i);
    if (i == n)
      printf("%d", cost);
    else
      printf("%d ", cost);
  }
  return 0;
}
