#include <bits/stdc++.h>
using namespace std;
int n, m, k, s;
const int _ = 100010;
queue<int> q[110][2];
vector<int> v[_];
vector<int> c[_];
int a[_];
int res[_], vis[_];
void bfs(int co) {
  int ptr = 0;
  while (!q[co][ptr & 1].empty()) {
    while (!q[co][ptr & 1].empty()) {
      int u = q[co][ptr & 1].front();
      q[co][ptr & 1].pop();
      if (vis[u] == co) continue;
      c[u].push_back(ptr);
      vis[u] = co;
      for (auto i : v[u])
        if (vis[i] - co) {
          q[co][ptr & 1 ^ 1].push(i);
        }
    }
    ptr++;
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    q[a[i]][0].push(i);
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i);
  }
  for (int i = 1; i <= n; i++) {
    sort(c[i].begin(), c[i].end());
    int t = 0;
    for (int j = 0; j < s; j++) t += c[i][j];
    printf("%d%c", t, " \n"[i == n]);
  }
}
