/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050
#define ll long long
#define ld long double
#define lli long long int
#define pb emplace_back
#define INF 1000000000
#define mod 1000000007
// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))
#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)
#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second
#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)
#define endl '\n'
template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}
#define scanarr(a,n) for(lli i=0;i<n;i++) cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}
#define printarr(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" "; cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" "; cout<<"\n";
#define FD(N) fixed<<setprecision(N)
#define deb(x) cout<<#x<<" "<<x<<endl;
// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
loop(i,10){
lli x=1;
}
return(chandan1());
}
int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
lli n , m , k , s;
cin>>n>>m>>k>>s;
lli a[n+1];
vi same[n+1];
FOR(i,1,n+1){
cin>>a[i];
same[a[i]].pb(i);
}
vi adj[n+1];
loop(i,m){
lli x,y;
cin>>x>>y;
adj[x].pb(y);
adj[y].pb(x);
}
/*
Now do multisource BFS from all nodes (having same a[i] ) and find shortest distance to other node
in first example after doing multisource_BFS from same valued nodes our 2-D matrix be like -
1 2 3 4 5 <-- node number
1 - 0 1 2 1 2
2 - 1 0 1 1 0
3 - 1 2 1 0 1
4 - 2 1 0 1 2
^
|
|
type of goods
Now we have to sort this column wise as we need "s" different products with minimum distance after that print
sum of top s values from each coulumn -
after sorting
1 2 3 4 5 <-- node number
0 0 0 0 0
1 1 1 1 1
1 1 1 1 2
2 2 2 1 2
sum top s elemnt = 2 2 2 2 3
*/
lli dist[k+1][n+1];
vi ans_cost[n+1];
for(lli type = 1; type<=k;type++)
{
bool vis[n+1]={0};
queue<lli>q;
// multipsource BFS
for(auto xt : same[type])
{
q.push(xt);
vis[xt]=1;
dist[type][xt] = 0;
}
while(!q.empty())
{
lli parent = q.front();
q.pop();
for(auto child : adj[parent])
{
if(!vis[child])
{
vis[child]=1;
q.push(child);
dist[type][child]=dist[type][parent]+1;
}
}
}
for(lli node = 1; node<=n;node++)
ans_cost[node].pb(dist[type][node]);
}
// for(lli i=1;i<=k;i++)
// {
// for(lli j =1;j<=n;j++)
// {
// cout<<dist[i][j]<<" ";
// }
// cout<<endl;
// }
for(lli i=1;i<=n;i++)
{
sort(all(ans_cost[i]));
lli sum= 0 ;
loop(j,s)
sum+=ans_cost[i][j];
cout<<sum<<" ";
}
}
return 0;
}