#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int inf = 1000000000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k, s;
  scanf("%d %d %d %d", &n, &m, &k, &s);
  vvi d(n, vi(k, inf));
  vvi g(n, vi());
  vi type(n);
  vector<queue<int> > vq(k, queue<int>());
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    --x;
    vq[x].push(i);
    d[i][x] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < k; ++i) {
    queue<int>& q = vq[i];
    vector<bool> vis(n, false);
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      if (!vis[cur]) {
        vis[cur] = true;
        for (int adj : g[cur]) {
          if (d[adj][i] > d[cur][i] + 1) {
            d[adj][i] = d[cur][i] + 1;
            q.push(adj);
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    sort(d[i].begin(), d[i].end());
    printf("%d\n", accumulate(d[i].begin(), d[i].begin() + s, 0));
  }
}
