#include <bits/stdc++.h>
using namespace std;
const int DIM = 1e5 + 5;
int Type[DIM], N, M, K, S;
int Ans[DIM][105], Is[DIM];
int Sum;
vector<int> V[DIM];
queue<int> Q;
int main() {
  cin >> N >> M >> K >> S;
  for (int i = 1; i <= N; i++) cin >> Type[i];
  for (int i = 1; i <= M; i++) {
    int a, b;
    cin >> a >> b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  memset(Ans, 0x3f3f3f3f, sizeof(Ans));
  for (int k = 1; k <= K; k++) {
    memset(Is, 0, sizeof(Is));
    for (int i = 1; i <= N; i++) {
      if (Type[i] == k) {
        Ans[i][k] = 0;
        Is[i] = 1;
        Q.push(i);
      }
    }
    while (!Q.empty()) {
      int nod = Q.front();
      for (int i = 0; i < V[nod].size(); i++) {
        if (Ans[V[nod][i]][k] > Ans[nod][k] + 1) {
          Ans[V[nod][i]][k] = Ans[nod][k] + 1;
          if (Is[V[nod][i]] == 0) Q.push(V[nod][i]), Is[V[nod][i]] = 1;
        }
      }
      Q.pop();
      Is[nod] = 0;
    }
  }
  for (int i = 1; i <= N; i++) {
    Sum = 0;
    sort(Ans[i] + 1, Ans[i] + K + 1);
    for (int j = 1; j <= S; j++) Sum += Ans[i][j];
    cout << Sum << " ";
  }
  return 0;
}
