#include <bits/stdc++.h>
using namespace std;
int cost[110][100010];
vector<int> G[100010];
vector<int> goods[110];
bool vis[100010];
int n, m, k, s;
void bfs(int g) {
  memset(vis, 0, sizeof(vis));
  queue<pair<int, int> > q;
  for (int i = 0; i < goods[g].size(); i++) {
    int town = goods[g][i];
    q.push(make_pair(town, 0));
    cost[g][town] = 0;
    vis[town] = true;
  }
  while (!q.empty()) {
    int u = q.front().first;
    int c = q.front().second;
    q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (vis[v]) {
        continue;
      }
      cost[g][v] = c + 1;
      vis[v] = true;
      q.push(make_pair(v, c + 1));
    }
  }
}
int main() {
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    goods[x].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i);
  }
  for (int i = 1; i <= n; i++) {
    vector<int> tmp(k + 1);
    for (int j = 1; j <= k; j++) {
      tmp[j] = cost[j][i];
    }
    sort(tmp.begin(), tmp.end());
    int sum = 0;
    for (int j = 1; j <= s; j++) {
      sum += tmp[j];
    }
    cout << sum << ' ';
  }
}
