#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
const int M = 112;
queue<pair<int, int> > q;
int n, m, k, s;
bool used[N][M];
vector<int> g[N];
int good[N], dp[N][M];
void solve() {
  while (q.size()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    for (auto x : g[i])
      if (!used[x][j])
        used[x][j] = true, dp[x][j] = dp[i][j] + 1, q.push(make_pair(x, j));
  }
}
void build() {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < k; ++j) dp[i][j] = INT_MAX, used[i][j] = false;
  for (int j = 0; j < k; ++j) {
    for (int i = 0; i < n; ++i)
      if (good[i] == j)
        used[i][j] = true, dp[i][j] = 0, q.push(make_pair(i, j));
    solve();
  }
  for (int i = 0; i < n; ++i) sort(dp[i], dp[i] + k);
  for (int i = 0; i < n; ++i)
    for (int j = 1; j < k; ++j) dp[i][j] += dp[i][j - 1];
}
int main() {
  scanf("%d %d %d %d", &n, &m, &k, &s);
  for (int i = 0; i < n; ++i) scanf("%d", &good[i]), --good[i];
  while (m-- > 0) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x, --y;
    g[x].push_back(y), g[y].push_back(x);
  }
  build();
  for (int i = 0; i < n; ++i)
    printf("%d%c", dp[i][s - 1], (i == n - 1) ? '\n' : ' ');
  return 0;
}
