#include <bits/stdc++.h>
using namespace std;
bool compare(long long int a, long long int b) { return (a < b); }
vector<int> a(100002);
vector<vector<int> > v(100002);
vector<vector<int> > w(101);
vector<vector<int> > d(101, vector<int>(100002));
void bfs(int i, int n) {
  for (int j = 1; j <= n; j++) d[i][j] = -1;
  queue<int> q;
  int m = w[i].size();
  for (int j = 0; j < m; j++) {
    q.push(w[i][j]);
    d[i][w[i][j]] = 0;
  }
  while (!q.empty()) {
    int b = q.front();
    q.pop();
    int c = v[b].size();
    for (int j = 0; j < c; j++) {
      if (d[i][v[b][j]] == -1) {
        d[i][v[b][j]] = d[i][b] + 1;
        q.push(v[b][j]);
      }
    }
  }
  return;
}
int main() {
  int n, m, s, k, aa, b;
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    w[a[i]].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    cin >> aa >> b;
    v[aa].push_back(b);
    v[b].push_back(aa);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i, n);
  }
  for (int i = 1; i <= n; i++) {
    vector<int> ans;
    for (int j = 1; j <= k; j++) ans.push_back(d[j][i]);
    nth_element(ans.begin(), ans.begin() + s, ans.begin() + k);
    cout << accumulate(ans.begin(), ans.begin() + s, 0) << " ";
  }
}
