#include <bits/stdc++.h>
using namespace std;
long n, k, m, s;
int a[100006];
vector<int> v[100006];
int mar[106][100006] = {0};
bool vis[106][100006];
int c[100006] = {0}, sum[100006] = {0}, goal[100006] = {0}, lev[106] = {0},
    lp[106], ha = 0;
int i, t1, t2;
queue<int> q[106];
queue<int> qq;
void bfs() {
  int r;
  i = qq.front();
  qq.pop();
  while (1) {
    r = q[i].front();
    q[i].pop();
    if (!goal[r]) {
      sum[r] += lev[i];
      c[r]++;
      if (c[r] == s) {
        goal[r] = 1;
        ha++;
        if (ha == n) break;
      }
    }
    for (vector<int>::iterator iter = v[r].begin(); iter != v[r].end();
         iter++) {
      if (vis[i][*iter]) continue;
      q[i].push(*iter);
      vis[i][*iter] = true;
    }
    if (lp[i] == r) {
      if (!q[i].empty()) {
        lev[i]++;
        lp[i] = q[i].back();
        qq.push(i);
        i = qq.front();
        qq.pop();
      } else {
        i = qq.front();
        qq.pop();
      }
    }
  }
}
int main() {
  cin >> n >> m >> k >> s;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    q[a[i]].push(i);
    vis[a[i]][i] = true;
    lp[a[i]] = i;
  }
  for (i = 0; i < m; i++) {
    cin >> t1 >> t2;
    v[t1].push_back(t2);
    v[t2].push_back(t1);
  }
  for (i = 1; i <= k; i++) {
    qq.push(i);
  }
  bfs();
  for (i = 1; i < n; i++) cout << sum[i] << " ";
  cout << sum[i];
  return 0;
}
