#include using namespace std; #define int long long #define pb push_back #define fi first #define se second #define rep(i,s,n) for(int i = s;i=(s);i--) #define all(v) (v).begin(),(v).end() #define chmin(a,b) a=min((a),(b)) #define chmax(a,b) a=max((a),(b)) #define endl '\n' #define IOS() ios_base::sync_with_stdio(0);cin.tie(0) typedef long long ll; typedef pairpint; typedef vectorvint; typedef vectorvpint; const ll MOD=1000000007,INF=1e18; int V,E,Q; vint g[100010]; signed main() { IOS(); cin>>V>>E; vint p(E),q(E); rep(i,0,E){ cin>>p[i]>>q[i]; p[i]--;q[i]--; g[p[i]].pb(q[i]); g[q[i]].pb(p[i]); } cin>>Q; vint a(Q); rep(i,0,Q){ cin>>a[i]; a[i]--; queueque; vint dist(100010,INF); dist[a[i]]=0; que.push(a[i]); int ma=0,ans=0; while(!que.empty()){ int now=que.front(); que.pop(); ans++; for(auto e:g[now]){ if(dist[e]!=INF)continue; dist[e]=dist[now]+1; chmax(ma,dist[e]); que.push(e); } } int tmp=1,cnt=0; while(tmp