#include <bits/stdc++.h>
using namespace std;
int vis[100005] = {0};
int a[100005];
int avail[100005][105];
vector<int> v[100005], ans;
vector<int> type[105];
queue<int> q;
int n, m, s, k, i, j;
void find(int item) {
  for (auto it : type[item]) {
    vis[it] = 1;
    q.push(it);
  }
  int node;
  while (!q.empty()) {
    node = q.front();
    q.pop();
    for (auto it : v[node]) {
      if (!vis[it]) {
        vis[it] = 1;
        q.push(it);
        avail[it][item] = min(avail[it][item], avail[node][item] + 1);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y, c, ansi;
  cin >> n >> m >> k >> s;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    type[a[i]].push_back(i);
  }
  while (m--) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= k; j++) {
      if (j == a[i])
        avail[i][j] = 0;
      else
        avail[i][j] = 100005;
    }
  }
  for (i = 1; i <= k; i++) {
    fill(vis, vis + n + 1, 0);
    find(i);
  }
  for (i = 1; i <= n; i++) {
    ans.clear();
    ansi = 0;
    c = 0;
    for (j = 1; j <= k; j++) {
      ans.push_back(avail[i][j]);
    }
    sort(ans.begin(), ans.end());
    for (auto it : ans) {
      ansi = ansi + it;
      c++;
      if (c == s) break;
    }
    cout << ansi << " ";
  }
  return 0;
}
