#include <bits/stdc++.h>
using namespace std;
long long BS(vector<pair<long long, long long> > &PS, long long s, long long e,
             long long ser) {
  if (s > e) return s;
  long long mid = (s + e) / 2;
  if (PS[mid].first == ser) {
    return mid;
  } else if (PS[mid].first > ser) {
    return BS(PS, s, mid - 1, ser);
  } else
    return BS(PS, mid + 1, e, ser);
}
long long explore(vector<vector<long long> > &graph, long long s, long long SA,
                  vector<long long> &vis, long long &cutted) {
  SA++;
  vis[s] = 1;
  for (long long i = 0; i < graph[s].size(); i++) {
    if (vis[graph[s][i]] == 0) {
      SA += explore(graph, graph[s][i], 0, vis, cutted);
    }
  }
  if (SA % 2 == 0) {
    cutted++;
    return 0;
  } else
    return SA;
}
void BFS(vector<vector<long long> > &G, long long s, vector<long long> &level) {
  level[s] = 1;
  queue<long long> Q;
  Q.push(s);
  while (!Q.empty()) {
    long long x = Q.front();
    Q.pop();
    for (long long i = 0; i < G[x].size(); i++) {
      if (level[G[x][i]] == 0) {
        Q.push(G[x][i]);
        level[G[x][i]] = level[x] + 1;
      }
    }
  }
}
void DFS(vector<vector<long long> > &G, vector<long long> &vis, long long s,
         long long counter) {
  vis[s] = counter;
  for (long long i = 0; i < G[s].size(); i++) {
    if (vis[G[s][i]] == 0) {
      DFS(G, vis, G[s][i], counter);
    }
  }
}
int main() {
  long long t = 1;
  while (t--) {
    long long n, m, i, j, k, l, w, q, u, r, v, c, h, p, d, s;
    cin >> n >> m >> k >> s;
    vector<vector<long long> > goods(k + 1);
    for (i = 1; i <= n; i++) {
      cin >> u;
      goods[u].push_back(i);
    }
    vector<vector<long long> > G(n + 1);
    for (i = 1; i <= m; i++) {
      cin >> u >> v;
      G[u].push_back(v);
      G[v].push_back(u);
    }
    vector<vector<long long> > ANS(n + 1);
    for (i = 1; i <= k; i++) {
      vector<long long> dist(n + 1, 1e9 + 7);
      queue<long long> Q;
      for (j = 0; j < goods[i].size(); j++) {
        Q.push(goods[i][j]);
        dist[goods[i][j]] = 0;
      }
      while (!Q.empty()) {
        long long temp = Q.front();
        Q.pop();
        for (j = 0; j < G[temp].size(); j++) {
          if (dist[G[temp][j]] > (dist[temp] + 1)) {
            Q.push(G[temp][j]);
            dist[G[temp][j]] = (dist[temp] + 1);
          }
        }
      }
      for (j = 1; j <= n; j++) {
        ANS[j].push_back(dist[j]);
      }
    }
    for (i = 1; i <= n; i++) {
      sort(ANS[i].begin(), ANS[i].end());
      long long min_sum = 0;
      for (j = 0; j < s; j++) {
        min_sum += ANS[i][j];
      }
      cout << min_sum << " ";
    }
  }
  return 0;
}
