rt
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug() cerr<<"I Will AK\n"
#define N 200007
vector<int> g[N];
int dis[N];
int n,m,k;
struct node{
int v,t,stt;
}que[N];
int st[N];
int t[N];
signed main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n>>m>>k;
int ll=1,rr=0;
for(int i=1;i<=k;++i){
cin>>que[++rr].v;
que[rr].t=0;
que[rr].stt=que[rr].v;
st[que[rr].v]=que[rr].v;
}
for(int i=1;i<=m;++i){
int u,v;
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
while(ll<=rr){
auto u=que[ll++];
//cout<<u.v<<'\n';
//_sleep(500);
for(auto v:g[u.v]){
if(st[v]!=0&&st[v]!=u.stt){
//_sleep(500);
if(dis[u.stt]) dis[u.stt]=min(dis[u.stt],(v==st[v]?0:dis[v])+dis[u.v]+1);
else dis[u.stt]=(v==st[v]?0:dis[v])+dis[u.v]+1;
//printf("st:%d v:%d u.v:%d l:%d\n",u.stt,v,u.v,dis[u.v]);
continue;
}
if(dis[v]){
continue;
}
if(v!=u.stt) dis[v]=u.t+1;
st[v]=u.stt,que[++rr]={v,u.t+1,u.stt};
//printf("IN:%d dis:%d\n",v,dis[v]);
}
}
for(int i=1;i<=n;++i){
cout<<(dis[i]==0?-1ll:dis[i])<<' ';
}
return 0;
}