#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void get_it_done() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
const long long N = 1e5 + 5;
long long n, m, k, s;
vector<long long> adjList[N], goods[N], cost[N];
long long arr[N], dp[105][N];
bool visited[N];
int32_t main() {
  get_it_done();
  long long t = 1;
  while (t--) {
    cin >> n >> m >> k >> s;
    for (long long i = 1; i < n + 1; ++i)
      cin >> arr[i], goods[arr[i]].push_back(i);
    for (long long i = 0; i < m; ++i) {
      long long u, v;
      cin >> u >> v;
      adjList[u].push_back(v);
      adjList[v].push_back(u);
    }
    if (s == 1) {
      for (long long i = 0; i < n; ++i) {
        cout << 0 << " ";
      }
      cout << "\n";
      continue;
    }
    for (long long i = 1; i < k + 1; ++i) {
      memset(visited, 0, sizeof(visited));
      queue<long long> q;
      for (auto x : goods[i]) {
        visited[x] = 1;
        q.push(x);
      }
      while (!q.empty()) {
        long long node = q.front();
        q.pop();
        for (auto x : adjList[node]) {
          if (!visited[x]) {
            dp[i][x] = dp[i][node] + 1;
            visited[x] = 1;
            q.push(x);
          }
        }
      }
      for (long long j = 1; j < n + 1; ++j) {
        cost[j].push_back(dp[i][j]);
      }
    }
    for (long long i = 1; i < n + 1; ++i) {
      sort(cost[i].begin(), cost[i].end());
      long long ans = 0;
      for (long long j = 0; j < s; ++j) {
        ans += cost[i][j];
      }
      cout << ans << " ";
    }
    cout << "\n";
  }
}
