#include <bits/stdc++.h>
using namespace std;
int a[100005], sss;
vector<int> v[100005];
int vis[100005];
int bfs(int s) {
  int level[100005];
  int ans = 0;
  unordered_set<int> tmpp;
  queue<int> q;
  q.push(s);
  level[s] = 0;
  vis[s] = s;
  while (!q.empty() && tmpp.size() != sss) {
    int p = q.front();
    q.pop();
    if (tmpp.find(a[p]) == tmpp.end()) {
      tmpp.insert(a[p]);
      ans += level[p];
    }
    if (tmpp.size() == sss) {
      break;
    }
    for (int i = 0; i < v[p].size(); i++) {
      if (vis[v[p][i]] != s) {
        level[v[p][i]] = level[p] + 1;
        q.push(v[p][i]);
        vis[v[p][i]] = s;
      }
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, j, n, m, k, x, y;
  cin >> n >> m >> k >> sss;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    cout << bfs(i) << " ";
  }
  return 0;
}
