#include <bits/stdc++.h>
const double Pi = 3.14159265;
const int N = 2e5 + 10;
const unsigned long long base = 163;
const int INF = 0x3f3f3f3f;
using namespace std;
int a[N];
int n, m, k, s;
int dis[N][105];
vector<int> vec[N];
void bfs(int st) {
  queue<int> q;
  q.push(st + n);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < vec[u].size(); i++) {
      int v = vec[u][i];
      if (!dis[v][st]) {
        dis[v][st] = dis[u][st] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    vec[n + a[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) bfs(i);
  for (int i = 1; i <= n; i++) {
    sort(dis[i] + 1, dis[i] + k + 1);
    int sum = 0;
    for (int j = 1; j <= s; j++) sum += dis[i][j];
    cout << sum - s << " ";
  }
  return 0;
}
