#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
constexpr int mod1 = 998244353;
vector<int> dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
bool inside(int y, int x, int h, int w) {
  if (y < h && y >= 0 && x < w && x >= 0) return true;
  return false;
}
const int inf = 1000000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<vector<int>> a(k);
  for (int i = 0; i < (n); ++i) {
    int t;
    cin >> t;
    t--;
    a.at(t).push_back(i);
  }
  vector<vector<int>> g(n, vector<int>());
  for (int i = 0; i < (m); ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<int>> ans(n, vector<int>(k));
  vector<int> dist(n);
  queue<int> q;
  for (int i = 0; i < (k); ++i) {
    for (int j = 0; j < (n); ++j) dist.at(j) = inf;
    for (int j = 0; j < (a.at(i).size()); ++j) {
      dist.at(a[i][j]) = 0;
      q.push(a[i][j]);
    }
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int j = 0; j < (g.at(cur).size()); ++j) {
        int next = g[cur][j];
        if (dist[next] > dist[cur] + 1) {
          dist[next] = dist[cur] + 1;
          q.push(next);
        }
      }
    }
    for (int j = 0; j < (n); ++j) {
      ans[j][i] = dist[j];
    }
  }
  for (int i = 0; i < (n); ++i) {
    int sum = 0;
    sort(ans[i].begin(), ans[i].end());
    for (int j = 0; j < (s); ++j) sum += ans[i][j];
    if (i == n - 1)
      cout << sum << endl;
    else
      cout << sum << " ";
  }
}
