#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> goods, g;
vector<int> cost;
int n;
vector<vector<int>> d(105, vector<int>(100005, -1));
void bfs(vector<int>& nds, vector<int>& dis) {
  queue<int> q;
  for (auto& i : nds) {
    q.push(i);
    dis[i] = 0;
  }
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    for (auto& ch : g[top]) {
      if (dis[ch] == -1) {
        dis[ch] = dis[top] + 1;
        q.push(ch);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  goods = vector<vector<int>>(k);
  g = vector<vector<int>>(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    goods[x].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < k; i++) {
    bfs(goods[i], d[i]);
  }
  for (int i = 0; i < n; i++) {
    vector<int> v;
    for (int j = 0; j < k; j++) {
      v.push_back(d[j][i]);
    }
    sort(v.begin(), v.end());
    cout << accumulate(v.begin(), v.begin() + s, 0) << " ";
  }
  return 0;
}
