#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_map>
#include<cmath>
using namespace std;
vector<int>v[1000001]; vector<int>v1;
int main()
{
int n, m, t1, t2, q;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> t1 >> t2;
v[t1].push_back(t2);
v[t2].push_back(t1);
}
for (int i = 0; i < m; i++)
{
cin >> q;
v1.clear();
int flag = 1;
for (int j = 0; j < q; j++)
{
cin >> t1;
v1.push_back(t1);
}
for (int j = 0; j < v1.size(); j++)
{
for (int q = 0; q < v[v1[j]].size(); q++)
{
if (find(v1.begin(), v1.end(), v[v1[j]][q]) != v1.end())
{
flag = 0;
break;
}
}
}
if (!flag)
{
cout << "No" << endl;
}
else
{
cout << "Yes" << endl;
}
}
}