#include <bits/stdc++.h>
using namespace std;
bitset<100000> visited, gds;
vector<vector<int> > adjsM(100000, vector<int>());
vector<int> goods(100000, 0);
vector<int> level(100000, 0);
void BFS(int t, int s) {
  level[t] = 0;
  queue<int> q;
  q.push(t);
  int goodsCounter = 0;
  int cost = 0;
  while (!q.empty()) {
    int town = q.front();
    q.pop();
    if (!gds.test(goods[town])) {
      gds.set(goods[town]);
      goodsCounter++;
      cost += level[town];
    }
    if (goodsCounter == s) break;
    for (int i = 0; i < adjsM[town].size(); i++) {
      int nextTown = adjsM[town][i];
      if (!visited.test(nextTown)) {
        q.push(nextTown);
        level[nextTown] = level[town] + 1;
        visited.set(nextTown);
      }
    }
  }
  visited.reset();
  gds.reset();
  cout << cost;
}
int main(int argc, char *argv[]) {
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    goods[i] = ai;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adjsM[x - 1].push_back(y - 1);
    adjsM[y - 1].push_back(x - 1);
  }
  BFS(0, s);
  for (int i = 1; i < n; i++) {
    cout << " ";
    BFS(i, s);
  }
  cout << '\n';
  return 0;
}
