#include <bits/stdc++.h>
using namespace std;
int n, m, k, l, i, j, a, b, res, f[100005], d[100005], g[100005][105];
vector<int> v[100005];
queue<pair<int, int> > q[105];
string s;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k >> l;
  for (i = 1; i <= n; i++) {
    cin >> d[i];
    q[d[i]].push({i, 0});
  }
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= k; j++) {
      g[i][j] = 10000000;
    }
    g[i][d[i]] = 0;
  }
  for (i = 1; i <= k; i++) {
    while (q[i].size() > 0) {
      a = q[i].front().first;
      b = q[i].front().second;
      q[i].pop();
      if (b != g[a][i]) continue;
      for (j = 0; j < v[a].size(); j++) {
        int to = v[a][j];
        if (g[to][i] > b + 1) {
          g[to][i] = b + 1;
          q[i].push({to, b + 1});
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= k; j++) {
      f[j] = g[i][j];
    }
    sort(f + 1, f + k + 1);
    res = 0;
    for (j = 1; j <= l; j++) {
      res += f[j];
    }
    cout << res << endl;
  }
}
