#include <bits/stdc++.h>
using namespace std;
vector<long long> a[100005], foo(100005);
bool b[100005];
void solve() {
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  for (long long i = 1; i <= n; i++) cin >> foo[i];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  memset(b, false, sizeof(b));
  long long dp[k + 1][n + 1];
  for (long long i = 0; i <= k; i++) {
    for (long long j = 0; j <= n; j++) dp[i][j] = 1e18;
  }
  vector<long long> tmp[k + 1];
  for (long long i = 1; i <= n; i++) {
    tmp[foo[i]].push_back(i);
  }
  for (long long i = 1; i <= k; i++) {
    queue<long long> q;
    long long sz = tmp[i].size();
    for (long long j = 0; j < sz; j++) {
      q.push(tmp[i][j]);
      dp[i][tmp[i][j]] = 0;
    }
    memset(b, false, sizeof(b));
    while (!q.empty()) {
      long long x = q.front();
      b[x] = true;
      q.pop();
      for (long long j = 0; j < a[x].size(); j++) {
        dp[i][a[x][j]] = min(dp[i][a[x][j]], dp[i][x] + 1);
        if (b[a[x][j]] == false) {
          b[a[x][j]] = true;
          q.push(a[x][j]);
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    vector<long long> temp;
    for (long long j = 1; j <= k; j++) temp.push_back(dp[j][i]);
    sort(temp.begin(), temp.end());
    long long cnt = 0;
    for (long long j = 0; j < s; j++) cnt += temp[j];
    cout << cnt << " ";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  t = 1;
  while (t--) solve();
}
