#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, inf = 1e9;
vector<int> adj[maxn];
int n, m, k, s, dis[maxn][105], a[maxn];
bitset<maxn> vis;
void bfs(int color) {
  queue<int> q;
  for (int i = (1); i <= (n); i++) {
    if (a[i] == color) {
      vis[i] = 1;
      q.push(i);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : adj[u]) {
      dis[v][color] = min(dis[v][color], dis[u][color] + 1);
      if (vis[v]) continue;
      q.push(v);
      vis[v] = 1;
    }
  }
  for (int i = (1); i <= (n); i++) vis[i] = 0;
}
void solve(int testcase) {
  cin >> n >> m >> k >> s;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  for (int i = (1); i <= (m); i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (k); j++) {
      if (j == a[i]) continue;
      dis[i][j] = inf;
    }
  }
  for (int i = (1); i <= (k); i++) bfs(i);
  for (int i = (1); i <= (n); i++) {
    sort(dis[i] + 1, dis[i] + 1 + k);
    int sum = 0;
    for (int j = (1); j <= (s); j++) sum += dis[i][j];
    cout << sum << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(10);
  clock_t b = clock();
  int t = 1;
  for (int tt = (1); tt <= (t); tt++) solve(tt);
  clock_t e = clock();
  cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
  return 0;
}
