#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
const int inf = 0x3f3f3f3f;
vector<int> g[maxn];
int a[maxn];
bool vis[maxn];
int d[maxn][100 + 5];
int main(void) {
  int n, m, k, s;
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    fill(d[i] + 1, d[i] + k + 1, inf);
  }
  for (int i = 1; i <= k; i++) {
    memset(vis, false, sizeof(vis));
    queue<int> q;
    for (int j = 1; j <= n; j++) {
      if (a[j] == i) {
        q.push(j);
        vis[j] = true;
        d[j][i] = 0;
      }
    }
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int j = 0; j < g[u].size(); j++) {
        int v = g[u][j];
        if (!vis[v]) {
          q.push(v);
          vis[v] = true;
          d[v][i] = d[u][i] + 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(d[i] + 1, d[i] + k + 1);
    int res = accumulate(d[i] + 1, d[i] + s + 1, 0);
    printf("%d%c", res, i == n ? '\n' : ' ');
  }
  return 0;
}
