#include <bits/stdc++.h>
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 4194300 + 5, mod = 1e9 + 7;
using namespace std;
long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return ((x / gcd(x, y)) * y); }
void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int dist[100005][105];
int vis[100005][105];
int arr[100005];
int n, m, k, s;
vector<int> adj[100005];
int main() {
  file();
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int c = 1; c <= k; c++) {
    queue<int> q;
    for (int i = 1; i <= n; i++) {
      if (arr[i] == c) {
        q.push(i);
        dist[i][c] = 0;
        vis[i][c] = 1;
      }
    }
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (int i : adj[x]) {
        if (!vis[i][c]) {
          vis[i][c] = 1;
          dist[i][c] = dist[x][c] + 1;
          q.push(i);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(dist[i] + 1, dist[i] + k + 1);
    long long ans = 0;
    for (int j = 1; j <= s; j++) ans += dist[i][j];
    cout << ans << " ";
  }
  return 0;
}
