#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1e4;
long long lim = 2e18;
long long n, so, m, k, s, first, second, u, v;
long long d[N][110], e[N], a[N], t;
vector<long long> ke[N];
queue<pair<long long, long long> > q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m >> k >> s;
  for (long long i = (long long)1; i <= (long long)n; i++) cin >> a[i];
  for (long long i = (long long)1; i <= (long long)m; i++) {
    cin >> first >> second;
    ke[first].push_back(second);
    ke[second].push_back(first);
  }
  for (long long i = (long long)0; i <= (long long)n; i++)
    for (long long j = (long long)0; j <= (long long)k; j++) (d)[i][j] = -1;
  for (long long i = (long long)1; i <= (long long)n; i++) {
    q.push(pair<long long, long long>(i, a[i]));
    e[i]++;
    d[i][a[i]] = 0;
  }
  while (q.size()) {
    tie(u, t) = q.front();
    q.pop();
    for (auto& v : ke[u]) {
      if (d[v][t] != -1) continue;
      if (e[v] == s) continue;
      e[v]++;
      d[v][t] = d[u][t] + 1;
      q.push(pair<long long, long long>(v, t));
    }
  }
  for (long long i = (long long)1; i <= (long long)n; i++)
    for (long long j = (long long)1; j <= (long long)k; j++)
      if (d[i][j] != -1) d[i][0] += d[i][j];
  for (long long i = (long long)1; i <= (long long)n; i++)
    cout << d[i][0] + 1 << " ";
}
