#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, a, b, d, u, v, w, k, s;
vector<int> g[N];
vector<int> mark[N];
int toSort[110];
int item[N];
bool vis[N][110];
void bfs(int it) {
  int i, j, sz, d;
  queue<int> q;
  for (i = 1; i <= n; ++i) {
    if (item[i] == it) {
      q.push(i);
      vis[i][it] = true;
    }
  }
  d = -1;
  while (!q.empty()) {
    sz = q.size();
    d++;
    while (sz--) {
      int u = q.front();
      q.pop();
      mark[u].push_back(d);
      for (j = 0; j < g[u].size(); ++j) {
        int v = g[u][j];
        if (!vis[v][it]) {
          vis[v][it] = true;
          q.push(v);
        }
      }
    }
  }
}
int main() {
  int i, j;
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (i = 1; i <= n; ++i) scanf("%d", &item[i]);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (i = 1; i <= k; ++i) {
    bfs(i);
  }
  int res;
  for (i = 1; i <= n; ++i) {
    for (j = 0; j < k; ++j) toSort[j] = mark[i][j];
    sort(toSort, toSort + k);
    res = 0;
    for (j = 0; j < s; ++j) {
      res += toSort[j];
    }
    printf("%d ", res);
  }
  printf("\n");
}
