#include <bits/stdc++.h>
using namespace std;
int n, m, t, s;
int type[100005];
int d[100005][100];
bool v[100005][100];
struct edge {
  int to, nxt;
} e[100005 << 1];
int edgenum = 0;
int lin[100005] = {0};
void add(int a, int b) {
  ++edgenum;
  e[edgenum].to = b;
  e[edgenum].nxt = lin[a];
  lin[a] = edgenum;
  ++edgenum;
  e[edgenum].to = a;
  e[edgenum].nxt = lin[b];
  lin[b] = edgenum;
  return;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &t, &s);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &type[i]);
  }
  int a, b;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    add(a, b);
  }
  for (int c = 1; c <= t; ++c) {
    queue<int> q;
    for (int k = 1; k <= n; ++k) {
      if (type[k] == c) {
        q.push(k);
        d[k][c] = 0;
        v[k][c] = true;
      }
    }
    while (!q.empty()) {
      int k = q.front();
      q.pop();
      for (int i = lin[k]; i != 0; i = e[i].nxt) {
        if (!v[e[i].to][c]) {
          d[e[i].to][c] = d[k][c] + 1;
          v[e[i].to][c] = true;
          q.push(e[i].to);
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    sort(d[i] + 1, d[i] + 1 + t);
    int ans = 0;
    for (int k = 1; k <= s; ++k) {
      ans += d[i][k];
    }
    cout << ans << endl;
  }
  return 0;
}
