#include <bits/stdc++.h>
using namespace std;
vector<int> G[100010];
vector<int> hw[110];
int ans[100010][110];
int jl[100010];
struct Zt {
  int stat;
  int now;
  int bs;
};
int main() {
  memset(ans, -1, sizeof(ans));
  int n, m, s, k;
  scanf("%d%d%d%d", &n, &m, &k, &s);
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    jl[i] = tmp;
    hw[tmp].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int tu, tv;
    scanf("%d%d", &tu, &tv);
    G[tu].push_back(tv);
    G[tv].push_back(tu);
  }
  for (int i = 1; i <= k; i++) {
    queue<Zt> q;
    for (int j = 0; j < hw[i].size(); j++) {
      q.push((Zt){hw[i][j], hw[i][j], 0});
      ans[hw[i][j]][i] = 0;
    }
    while (!q.empty()) {
      Zt k = q.front();
      q.pop();
      for (int j = 0; j < G[k.now].size(); j++) {
        if (ans[G[k.now][j]][jl[k.stat]] != -1) continue;
        ans[G[k.now][j]][jl[k.stat]] = k.bs + 1;
        q.push((Zt){k.stat, G[k.now][j], k.bs + 1});
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(ans[i] + 1, ans[i] + 1 + k);
    int tmp = 0;
    for (int j = 1; j <= s; j++) tmp += ans[i][j];
    cout << tmp << " ";
  }
  return 0;
}
