#include <bits/stdc++.h>
using std::queue;
queue<int> q;
using std::vector;
const int maxnm = 1e5 + 10;
int n, m, k, s, a[maxnm], x, y;
int dis[maxnm][110];
vector<int> e[maxnm];
vector<int> col[110];
int main() {
  memset(dis, -1, sizeof dis);
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    col[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int c = 1; c <= k; ++c) {
    for (int i = 0; i < (int)col[c].size(); ++i) {
      q.push(col[c][i]);
      dis[col[c][i]][c] = 0;
    }
    while (!q.empty()) {
      x = q.front();
      q.pop();
      for (int i = 0; i < (int)e[x].size(); ++i) {
        if (dis[e[x][i]][c] == -1) {
          dis[e[x][i]][c] = dis[x][c] + 1;
          q.push(e[x][i]);
        }
      }
    }
  }
  int ans;
  for (int i = 1; i <= n; ++i) {
    ans = 0;
    std::sort(dis[i] + 1, dis[i] + 1 + k);
    for (int j = 1; j <= s; ++j) {
      ans += dis[i][j];
    }
    printf("%d ", ans);
  }
}
