代码
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string a[100001];
string b[1001];
int main()
{
int n,m;
int k;
string s1,s2;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s1>>s2;
a[stoi(s1)]+=s2+"x";
a[stoi(s2)]+=s1+"x";
}
for(int i=0;i<m;i++){
cin>>k;
for(int j=0;j<k;j++){
cin>>b[j];
}
for(int j=0;j<k;j++){
if(a[stoi(b[j])]==""){
}
else{
for(int tmp=j+1;tmp<k;tmp++){
if(a[stoi(b[j])].find(b[tmp])!=string::npos){
cout<<"No"<<endl;
goto here;
}
}
}
}
cout<<"Yes"<<endl;
here:
;
}
return 0;
}