#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
long long int dis[N];
long long int ans[N];
vector<long long int> g[N];
vector<long long int> type[111];
vector<long long int> op[N];
bool vis[N];
long long int n, m, k, s;
void solve() {
  cin >> n >> m >> k >> s;
  for (long long int i = 1; i <= n; i++) {
    long long int x;
    cin >> x;
    type[x].push_back(i);
  }
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  queue<long long int> q;
  for (long long int i = 1; i <= k; i++) {
    if (type[i].size() == 0) continue;
    for (long long int i = 0; i <= n; i++) vis[i] = false;
    while (!q.empty()) q.pop();
    for (long long int x : type[i]) {
      dis[x] = 0;
      q.push(x);
      vis[x] = 1;
      dis[x] = 0;
      op[x].push_back(0);
    }
    while (!q.empty()) {
      long long int tp = q.front();
      q.pop();
      for (long long int y : g[tp]) {
        if (!vis[y]) {
          vis[y] = 1;
          dis[y] = dis[tp] + 1;
          q.push(y);
          op[y].push_back(dis[y]);
        }
      }
    }
  }
  for (long long int i = 1; i <= n; i++) {
    sort(op[i].begin(), op[i].end());
    long long int tot = 0;
    for (long long int j = 0; j < s; j++) tot += op[i][j];
    ans[i] = tot;
  }
  for (long long int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) solve();
  return 0;
}
