#include <bits/stdc++.h>
long long int maxx(long long int a, long long int b) { return a > b ? a : b; }
long long int minn(long long int a, long long int b) { return a > b ? b : a; }
using namespace std;
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1, 0};
int dy[] = {-1, 0, 1, 1, -1, 0, 1, -1, 0};
void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int poww(long long int base, long long int exp) {
  base %= 1000000007;
  long long int result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % 1000000007;
    base = (base * base) % 1000000007;
    exp >>= 1;
  }
  return result;
}
const int Max_N = 100100;
int dist[101][Max_N];
vector<int> a[Max_N], type[101];
void bfs(int t) {
  for (int i = 0; i <= 100000; i++) dist[t][i] = 1e9;
  queue<int> q;
  for (int i = 0; i < type[t].size(); i++)
    q.push(type[t][i]), dist[t][type[t][i]] = 0;
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (int i = 0; i < a[node].size(); i++) {
      if (dist[t][a[node][i]] > dist[t][node] + 1) {
        dist[t][a[node][i]] = dist[t][node] + 1;
        q.push(a[node][i]);
      }
    }
  }
  return;
}
int main() {
  boostIO();
  int n, m, k, seco3nd;
  cin >> n >> m >> k >> seco3nd;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    type[x].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v), a[v].push_back(u);
  }
  for (int i = 1; i <= k; i++) {
    bfs(i);
  }
  for (int i = 1; i <= n; i++) {
    priority_queue<int> q;
    int ans = 0;
    for (int j = 1; j <= k; j++) {
      q.push(-dist[j][i]);
    }
    for (int j = 0; j < seco3nd; j++) {
      ans = ans + -q.top();
      q.pop();
    }
    cout << ans << " ";
  }
}
