#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=220;
bool edge[maxn][maxn]={0},vis[maxn]={0};
int main(){
int N,M,K;
scanf("%d%d",&N,&M);
for(int i=0;i<M;i++){
int v1,v2;
scanf("%d%d",&v1,&v2);
edge[v1][v2]=edge[v2][v1]=true;
}
scanf("%d",&K);
for(int i=0;i<K;i++){
int tnum,pre,now,start;
bool ans=true;
fill(vis,vis+maxn,0);
scanf("%d%d",&tnum,&pre);
if(tnum!=N+1) ans=false;
vis[pre]=true;
start=pre; //
for(int j=1;j<tnum;j++){
scanf("%d",&now);
if(!edge[pre][now]) ans=false;
if(j==tnum-1) break;
else if(vis[now]) ans=false;
vis[now]=false;
pre=now;
}
if(now!=start) ans=false;
if(ans) printf("YES\n");
else printf("NO\n");
}
return 0;
}
PAT A1122
最新推荐文章于 2020-11-28 19:36:43 发布