#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int K = 101;
const int oo = 10000000;
int n, m, k, s;
int a[N];
int d[N][K];
vector<int> g[N];
vector<int> p[K];
int main() {
  cin >> n >> m >> k >> s;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
    p[a[i]].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 0; i < n; ++i) {
    fill(d[i], d[i] + k, oo);
  }
  function<void(const int)> bfs = [&](const int x) {
    queue<int> q;
    for (int v : p[x]) {
      q.push(v);
      d[v][x] = 0;
    }
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i : g[v]) {
        if (d[i][x] > d[v][x] + 1) {
          d[i][x] = d[v][x] + 1;
          q.push(i);
        }
      }
    }
  };
  for (int i = 0; i < k; ++i) {
    bfs(i);
  }
  for (int i = 0; i < n; ++i) {
    priority_queue<int> heap;
    heap.push(0);
    for (int j = 0; j < k; ++j) {
      if (j == a[i]) {
        continue;
      }
      if (heap.size() < s) {
        heap.push(d[i][j]);
      } else {
        if (heap.top() > d[i][j]) {
          heap.pop();
          heap.push(d[i][j]);
        }
      }
    }
    int sum = 0;
    while (!heap.empty()) {
      sum += heap.top();
      heap.pop();
    }
    cout << sum << " ";
  }
  cout << endl;
  return 0;
}
