#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, a[(int)1e5 + 5];
vector<int> adj[(int)1e5 + 5];
int vis[(int)1e5 + 5];
int dist[(int)1e5 + 5], sum;
void bfs(int src) {
  queue<int> q;
  q.push(src);
  set<int> ss;
  dist[src] = 0;
  vis[src] = src;
  sum = 0;
  ss.insert(a[src]);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto i : adj[u]) {
      if (vis[i] != src) {
        dist[i] = dist[u] + 1;
        vis[i] = src;
        q.push(i);
        int k = ss.size();
        ss.insert(a[i]);
        if (ss.size() > k) sum += dist[i];
        if (ss.size() == s) return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k >> s;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (s > 1) bfs(i + 1);
    cout << sum << " ";
  }
  cout << endl;
}
