#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,x,y) for(int i=x; i<=y; i++)

typedef long long ll;
main()
{
 //freopen("input.txt","r",stdin);
 //	freopen("output.txt","w",stdout);
 std::ios::sync_with_stdio(false);
 	ll n,m,k,val;
 	cin>>n>>m>>k;
 	map <ll,ll> freq;
 	REP(i,n)
 	{
 		cin>>val;
 		freq[val]++;
	}
	REP(i,m)
	{
		cin>>val;
		freq[val]--;
	}
	ll ret=0;
	map <int,int> :: iterator it=freq.end();
	for(it--;it!=freq.begin();it--)
	{
		ret+=(ll)it->second;
		if(ret>0)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");

}


#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,x,y) for(int i=x; i<=y; i++)

typedef long long ll;
main()
{
 //freopen("input.txt","r",stdin);
 //	freopen("output.txt","w",stdout);
 std::ios::sync_with_stdio(false);
 	ll n,m,k,val;
 	cin>>n>>m>>k;
 	map <ll,ll> freq;
 	REP(i,n)
 	{
 		cin>>val;
 		freq[val]++;
	}
	REP(i,m)
	{
		cin>>val;
		freq[val]--;
	}
	ll ret=0;
	map <ll,ll> :: iterator it=freq.end();
	for(it--;it!=freq.begin();it--)
	{
		ret+=(ll)it->second;
		if(ret>0)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");

}


#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,x,y) for(int i=x; i<=y; i++)

typedef long long ll;
main()
{
 //freopen("input.txt","r",stdin);
 //	freopen("output.txt","w",stdout);
 	int n,m,k;
 	cin>>n>>m>>k;
 	map <int,int> res1,res2;
 	REP(i,n)
 	{
 		int val;
 		cin>>val;
 		res1[val]++;
	}
	REP(i,m)
	{
		int val;
		cin>>val;
		res2[val]++;
	}
	map <int,int> final_weight;
	for(map <int,int> :: iterator it=res1.begin();it!=res1.end();it++)
	{
		int cur_type=it->first;
		if(res2.count(cur_type))
			final_weight[cur_type]=1;
		else
			final_weight[cur_type]=k;
	}
	for(map <int,int> :: iterator it=res2.begin();it!=res2.end();it++)
	{
		final_weight[it->first]=1;
	}
	ll ret1=0,ret2=0;
	for(map <int,int> :: iterator it=res1.begin();it!=res1.end();it++)
	{
		ret1+=(ll)(it->second)*(final_weight[it->first]);
	}
	for(map <int,int> :: iterator it=res2.begin();it!=res2.end();it++)
	{
		ret2+=(ll)(it->second)*(final_weight[it->first]);
	}
//	cout<<ret1<<" "<<ret2<<"\n";
	if(ret1>ret2)
		cout<<"YES";
	else
		cout<<"NO";
}


#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,x,y) for(int i=x; i<=y; i++)

typedef long long ll;
main()
{
 //freopen("input.txt","r",stdin);
 //	freopen("output.txt","w",stdout);
 	int n,m,k,val;
 	cin>>n>>m>>k;
 	map <int,int> freq;
 	REP(i,n)
 	{
 		cin>>val;
 		freq[val]++;
	}
	REP(i,m)
	{
		cin>>val;
		freq[val]--;
	}
	ll ret=0;
	map <int,int> :: iterator it=freq.end();
	for(it--;it!=freq.begin();it--)
	{
		ret+=it->second;
		if(ret>0)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
}


#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,x,y) for(int i=x; i<=y; i++)

typedef long long ll;
main()
{
 //freopen("input.txt","r",stdin);
 //	freopen("output.txt","w",stdout);
 std::ios::sync_with_stdio(false);
 	int n,m,k,val;
 	cin>>n>>m>>k;
 	map <int,int> freq;
 	REP(i,n)
 	{
 		cin>>val;
 		freq[val]++;
	}
	REP(i,m)
	{
		cin>>val;
		freq[val]--;
	}
	ll ret=0;
	map <int,int> :: iterator it=freq.end();
	for(it--;it!=freq.begin();it--)
	{
		ret+=(ll)it->second;
		if(ret>0)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");

}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	a.push_back(0);
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll tmp = 0, prev = 0, j = 0;
	for (ll i = 1; i <= n; i++)
	{
		while (b[j] < a[i])
		{
			b[j] = a[i-1];
			j++;
			if (j >= m) break;
		}
		if (j >= m) break;
	}

	while (j < m)
	{
		b[j] = a[n];
		j++;
	}

	ll n1 = b.size();
	for (ll i = 0; i < n1; i++) res += b[i];

	//print();

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
ll da[maxN], db[maxN];
vector<ll> a, b;
ll res, res1;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		da[x]++;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		db[x]++;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll tmp = 0, prev = 0, j;
	for (ll i = 0; i < n;)
	{
		ll ptr = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		res += tmp * (ptr - prev);
		tmp = a[i];
		prev = ptr + 1;
		//cout << prev << " " << tmp << " " << ptr << endl;
		i = upper_bound(a.begin(), a.end(), a[i]) - a.begin();
		//j = lower_bound(a.begin(), a.end(), a[i]) - a.begin();
		//cout << i << " " << j << endl;
		if (i == n)
		{
			res += tmp * (m - ptr);
			break;
		}
	}

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll prev = 0, j = m - 1;
	for (ll i = n - 1; i >= 0; i--)
	{
		if (a[i] == a[i+1] && i != n - 1) continue;
		while (b[j] >= a[i])
		{
			b[j] = a[i];
			j--;
			if (j < 0) break;
		}
		if (j < 0) break;
	}

	ll n1 = b.size();
	for (ll i = 0; i < n1; i++) res += b[i];

	//print();

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
ll da[maxN], db[maxN];
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		da[x]++;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		db[x]++;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n >= m && a[0] > b[0])
	{
		cout << "YES";
		return 0;
	}
	else if (n >= m)
	{
		cout << "NO";
		return 0;
	}

	ll tmp = 0, prev = 0, j;
	for (ll i = 0; i < n;)
	{
		ll ptr = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		res += tmp * (ptr - prev);
		tmp = a[i];
		prev = ptr + 1;
		//cout << prev << " " << tmp << " " << ptr << endl;
		i = upper_bound(a.begin(), a.end(), a[i]) - a.begin();
		//j = lower_bound(a.begin(), a.end(), a[i]) - a.begin();
		//cout << i << " " << j << endl;
		if (i == n)
		{
			res += tmp * (m - ptr);
			break;
		}
	}

	print();

	cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll j = n - 1;
	for (ll i = m - 1; i >= 0; i--)
	{
		if (b[i] >= a[j]) j--;
		else break;
		if (j < 0) break;
	}

	if (j > 0) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
ll da[maxN], db[maxN];
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	a.push_back(0);
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		da[x]++;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		db[x]++;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll tmp = 0, prev = 0, j = 0;
	for (ll i = 1; i <= n; i++)
	{
		while (b[j] < a[i])
		{
			b[j] = a[i-1];
			j++;
			if (j > m) break;
		}
		if (j > m) break;
	}

	while (j < m)
	{
		b[j] = a[n];
		j++;
	}

	ll n1 = b.size();
	for (ll i = 0; i < n1; i++) res += b[i];

	//print();

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	a.push_back(0);
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll j = n - 1;
	for (ll i = m - 1; i >= 0; i--)
	{
		if (b[i] >= a[j]) j--;
		else break;
		if (j < 0) break;
	}

	if (j > 0) cout << "NO";
	else cout << "YES";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll j = n - 1;
	for (ll i = m - 1; i >= 0; i--)
	{
		if (b[i] >= a[j]) j--;
		else break;
		if (j < 0) break;
	}

	if (j >= 0) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
ll da[maxN], db[maxN];
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		da[x]++;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		db[x]++;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n >= m && a[0] > b[0])
	{
		cout << "YES";
		return 0;
	}
	else if (n >= m)
	{
		cout << "NO";
		return 0;
	}

	ll tmp = 0, prev = 0, j;
	for (ll i = 0; i < n;)
	{
		ll ptr = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		res += tmp * (ptr - prev);
		tmp = a[i];
		prev = ptr + 1;
		//cout << prev << " " << tmp << " " << ptr << endl;
		i = upper_bound(a.begin(), a.end(), a[i]) - a.begin();
		//j = lower_bound(a.begin(), a.end(), a[i]) - a.begin();
		//cout << i << " " << j << endl;
		if (i == n)
		{
			res += tmp * (m - ptr);
			break;
		}
	}

	//print();

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
#define maxN 100009

ll n, m, k;
ll x;
vector<ll> a, b;
ll res, res1;

void print ()
{
	ll n1 = a.size();
	for (ll i = 0; i < n1; i++) cout << a[i] << " ";
	cout << endl;
	n1 = b.size();
	for (ll i = 0; i < n1; i++) cout << b[i] << " ";
	cout << endl;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> k;
	a.push_back(0);
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
		res1 += x;
	}
	for (ll i = 0; i < m; i++)
	{
		cin >> x;
		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll j = m - 1;
	for (ll i = n; i >= 0; i--)
	{
		if (a[i] == a[i+1] && i != n) continue;
		while (b[j] >= a[i])
		{
			b[j] = a[i];
			j--;
			if (j < 0) break;
		}
		if (j < 0) break;
	}

	//ll n1 = b.size();
	for (ll i = 0; i < m; i++) res += b[i];

	//print();

	//cout << res << " " << res1 << '\n';

	if (res < res1) cout << "YES";
	else cout << "NO";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long n,m,k;
   cin>>n>>m>>k;
   long long x[100005]={0},xx[100005]={0};
   for(int i=0;i<n;i++)
       cin>>x[i];
   for(int j=0;j<m;j++)
       cin>>xx[j];
       sort(x,x+n);
       sort(xx,xx+m);
       long flag=0;
       if(n>m)
       flag=1;
       else
        {
       for(int i=0;i<n;i++)
       {
           if(x[i]>xx[m-n+i])
            flag=1;
       }
        }
        if(flag)  cout<<"YES\n";
            else
            cout<<"NO\n";
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&300<=i&&i<350){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<' ';
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&i<100){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&750<=i&&i<800){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&850<=i&&i<900){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&400<=i&&i<450){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#include <fstream>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    ifstream fi("data.in");
    cin.rdbuf(fi.rdbuf());
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<' ';
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&50<=i&&i<100){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893){
            cout<<u<<' '<<v<<' ';
            if(i%100==0)cout<<endl;
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893){
            cout<<u<<' '<<v<<' ';
            if(i%50==0)cout<<endl;
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#include <fstream>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    //cout<<' '<<cur<<' '<<root<<' '<<d<<endl;
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    //ifstream fi("data.in");
    //cin.rdbuf(fi.rdbuf());
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        ans=true;
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<' ';
            if(path[u]==true||path[tree[u].p]==true){
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        for(j=0;j<k;++j){
            cin>>u;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&50<=i&&i<100){
            cout<<u<<' '<<v<<' ';
            if(i%50==0)cout<<endl;
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&650<=i&&i<700){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&600<=i&&i<650){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
map<int,vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={true};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        for(j=0;j<k;++j){
            cin>>u;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&100<=i&&i<150){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&900<=i&&i<950){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&800<=i&&i<850){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&550<=i&&i<600){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&500<=i&&i<550){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&i<100){
            cout<<u<<' '<<v<<' ';
            if(i%50==0)cout<<endl;
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


//1. build the tree by store every node's father and the depth
//2. in each query,walk through the array,if the node's father is on the path,then continue,else if the father's depth is lower than ...
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define MAXN (int(2e5))
using namespace std;
const char *yes="YES",*no="NO";
struct Node{
    int p;
    int d;
};
vector<vector<int>>rela;

Node tree[MAXN+1];
void build(int cur,int root,int d)
{
    tree[cur].p=root;
    tree[cur].d=d;
    for(auto i:rela[cur]){
        if(i==root)continue;
        build(i,cur,d+1);
    }
}
bool path[MAXN+1]={false};
int depth;
int main(int argc,char ** argv)
{
    int n,m,i,j,u,v,k;
    bool ans;
    cin>>n>>m;
    rela.resize(n+1);
    for(i=0;i<n-1;++i){
        cin>>u>>v;
        if(n==1000&&m==3893&&200<=i&&i<250){
            cout<<u<<' '<<v<<' ';
        }
        rela[u].push_back(v);
        rela[v].push_back(u);
    }
    build(1,0,0);
    for(i=0;i<m;++i){
        fill(path+2,path+n+1,false);
        depth=0;
        path[1]=true;
        cin>>k;
        //if(n==1000&&m==3893)cout<<k<<endl;
        for(j=0;j<k;++j){
            cin>>u;
            //if(n==1000&&m==3893)cout<<u<<endl;
            if(path[u]==true||path[tree[u].p]==true){
                ans=true;
            }
            else{
                v=u;
                while(tree[v].d>depth)v=tree[v].p;
                if(path[v]){
                    depth=tree[u].d-1;
                    while(tree[u].p!=v)u=tree[u].p,path[u]=true;
                    ans=true;
                }
                else ans=false;
            }
        }
        cout<<(ans?yes:no)<<endl;
    }
    //system("pause > nul");
    return 0;
}


/**
 *  “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
 *
 *  author  :   prodipdatta7
 *  created :   Thursday 26-March, 2020  10:41:56 PM
**/

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")

using namespace std ;
using namespace __gnu_pbds ;

#define     ll          long long
#define     ld          long double
#define     ull         unsigned long long
#define     pii         pair<int,int>
#define     pll         pair<ll,ll>
#define     vi          vector<int>
#define     vll         vector<ll>
#define     vvi         vector<vector<int>>
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     all(x)      x.begin() , x.end()
#define     rall(x)     x.rbegin() , x.rend()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     fread       freopen("input.txt","r",stdin)
#define     fwrite      freopen("output.txt","w",stdout)
#define     TN          typename

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

/*###############-> Input Section <-###############*/

template <TN T> inline void Int(T &a) {
    bool minus = false; a = 0; char ch = getchar();
    while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
    if (ch == '-') minus = true; else a = ch - '0';
    while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
    if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}

/*###############-> Debugger <-###############*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1} ;

/*###############-> Constraints <-###############*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

/*...... ! Code starts from here ! ......*/

vector < int > edge[N] ;
int in[N], out[N], par[N][20], dep[N], cur ;

void dfs(int s, int p = 0) {
    par[s][0] = p ;
    dep[s] = 1 + dep[p] ;
    in[s] = ++cur ;
    for (int i = 1 ; i < 20 ; ++i)
        par[s][i] = par[par[s][i - 1]][i - 1] ;
    for (int i : edge[s]) {
        if (i == p)continue ;
        dfs(i, s) ;
    }
    out[s] = ++cur ;
}

bool cmp(int a, int b) {
    return dep[a] > dep[b] ;
}

bool ancestor(int x, int y) {
    return in[x] <= in[y] and out[x] >= out[y] ;
}

int main() {
    // ios_base::sync_with_stdio(false) ;
    // cin.tie(NULL) ; cout.tie(NULL) ;
    int test = 1 , tc = 0 ;
    //Int(test) ;
    while (test--) {
        int n, m ; Int(n, m) ;
        for (int i = 1 ; i < n ; ++i) {
            int x, y ;
            Int(x, y) ;
            edge[x].pb(y) ;
            edge[y].pb(x) ;
        }
        cur = 0 ;
        dfs(1) ;
        par[1][0] = 1 ;
        while (m--) {
            int k ; Int(k) ;
            vi v(k) ;
            for (int &i : v) {
                Int(i) ;
                i = par[i][0] ;
            }
            sort(all(v), cmp) ;
            int i = 1, ok = 1 ;
            cur = v[0] ;
            for (int i = 1 ; i < k ; ++i) {
                if (ancestor(v[i], cur))cur = v[i] ;
                else {
                    ok = 0 ;
                    break ;
                }
            }
            if (!ok)puts("NO") ;
            else puts("YES") ;
        }
    }
    return 0 ;
}


/**
 *  “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
 *
 *  author  :   prodipdatta7
 *  created :   Thursday 26-March, 2020  10:41:56 PM
**/

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")

using namespace std ;
using namespace __gnu_pbds ;

#define     ll          long long
#define     ld          long double
#define     ull         unsigned long long
#define     pii         pair<int,int>
#define     pll         pair<ll,ll>
#define     vi          vector<int>
#define     vll         vector<ll>
#define     vvi         vector<vector<int>>
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     all(x)      x.begin() , x.end()
#define     rall(x)     x.rbegin() , x.rend()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     fread       freopen("input.txt","r",stdin)
#define     fwrite      freopen("output.txt","w",stdout)
#define     TN          typename

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

/*###############-> Input Section <-###############*/

template <TN T> inline void Int(T &a) {
    bool minus = false; a = 0; char ch = getchar();
    while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
    if (ch == '-') minus = true; else a = ch - '0';
    while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
    if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}

/*###############-> Debugger <-###############*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1} ;

/*###############-> Constraints <-###############*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

/*...... ! Code starts from here ! ......*/

vector < int > edge[N] ;
int in[N], out[N], par[N], dep[N], cur ;

void dfs(int s, int p = 0) {
    par[s] = p ;
    dep[s] = 1 + dep[p] ;
    in[s] = ++cur ;
    for (int i : edge[s]) {
        if (i == p)continue ;
        dfs(i, s) ;
    }
    out[s] = ++cur ;
}

bool ancestor(int x, int y) {
    return in[x] <= in[y] and out[x] >= out[y] ;
}

int main() {
    // ios_base::sync_with_stdio(false) ;
    // cin.tie(NULL) ; cout.tie(NULL) ;
    int test = 1 , tc = 0 ;
    //Int(test) ;
    while (test--) {
        int n, m ; Int(n, m) ;
        for (int i = 1 ; i < n ; ++i) {
            int x, y ;
            Int(x, y) ;
            edge[x].pb(y) ;
            edge[y].pb(x) ;
        }
        cur = 0 ;
        dfs(1) ;
        par[1] = 1 ;
        while (m--) {
            int k ; Int(k) ;
            vi v(k) ;
            int deepestNode = 0, len = 0 ;
            for (int &i : v) {
                Int(i) ;
                i = par[i] ;
                if(dep[i] > len){
                    len = dep[i] ;
                    deepestNode = i ;
                }
            }
            int ok = 1 ;
            for (int i : v) {
                ok &= ancestor(i, deepestNode) ;
                if(!ok)break ;
            }
            if (!ok)puts("NO") ;
            else puts("YES") ;
        }
    }
    return 0 ;
}


/**
 *  “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
 *
 *  author  :   prodipdatta7
 *  created :   Thursday 26-March, 2020  10:41:56 PM
**/

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")

using namespace std ;
using namespace __gnu_pbds ;

#define     ll          long long
#define     ld          long double
#define     ull         unsigned long long
#define     pii         pair<int,int>
#define     pll         pair<ll,ll>
#define     vi          vector<int>
#define     vll         vector<ll>
#define     vvi         vector<vector<int>>
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     all(x)      x.begin() , x.end()
#define     rall(x)     x.rbegin() , x.rend()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     fread       freopen("input.txt","r",stdin)
#define     fwrite      freopen("output.txt","w",stdout)
#define     TN          typename

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

/*###############-> Input Section <-###############*/

template <TN T> inline void Int(T &a) {
    bool minus = false; a = 0; char ch = getchar();
    while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
    if (ch == '-') minus = true; else a = ch - '0';
    while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
    if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}

/*###############-> Debugger <-###############*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1} ;

/*###############-> Constraints <-###############*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

/*...... ! Code starts from here ! ......*/

vector < int > edge[N] ;
int in[N], out[N], par[N], dep[N], cur ;

void dfs(int s, int p = 0) {
    par[s] = p ;
    dep[s] = 1 + dep[p] ;
    in[s] = ++cur ;
    for (int i : edge[s]) {
        if (i == p)continue ;
        dfs(i, s) ;
    }
    out[s] = ++cur ;
}

bool cmp(int a, int b) {
    return dep[a] > dep[b] ;
}

bool ancestor(int x, int y) {
    return in[x] <= in[y] and out[x] >= out[y] ;
}

int main() {
    // ios_base::sync_with_stdio(false) ;
    // cin.tie(NULL) ; cout.tie(NULL) ;
    int test = 1 , tc = 0 ;
    //Int(test) ;
    while (test--) {
        int n, m ; Int(n, m) ;
        for (int i = 1 ; i < n ; ++i) {
            int x, y ;
            Int(x, y) ;
            edge[x].pb(y) ;
            edge[y].pb(x) ;
        }
        cur = 0 ;
        dfs(1) ;
        par[1] = 1 ;
        while (m--) {
            int k ; Int(k) ;
            vi v(k) ;
            for (int &i : v) {
                Int(i) ;
                i = par[i] ;
            }
            sort(all(v), cmp) ;
            int i = 1, ok = 1 ;
            cur = v[0] ;
            for (int i = 1 ; i < k ; ++i) {
                if (ancestor(v[i], cur))cur = v[i] ;
                else {
                    ok = 0 ;
                    break ;
                }
            }
            if (!ok)puts("NO") ;
            else puts("YES") ;
        }
    }
    return 0 ;
}


/**
 *  “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
 *
 *  author  :   prodipdatta7
 *  created :   Thursday 26-March, 2020  10:41:56 PM
**/

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")

using namespace std ;
using namespace __gnu_pbds ;

#define     ll          long long
#define     ld          long double
#define     ull         unsigned long long
#define     pii         pair<int,int>
#define     pll         pair<ll,ll>
#define     vi          vector<int>
#define     vll         vector<ll>
#define     vvi         vector<vector<int>>
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     all(x)      x.begin() , x.end()
#define     rall(x)     x.rbegin() , x.rend()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     fread       freopen("input.txt","r",stdin)
#define     fwrite      freopen("output.txt","w",stdout)
#define     TN          typename

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

/*###############-> Input Section <-###############*/

template <TN T> inline void Int(T &a) {
    bool minus = false; a = 0; char ch = getchar();
    while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
    if (ch == '-') minus = true; else a = ch - '0';
    while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
    if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}

/*###############-> Debugger <-###############*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = {-1, 0, 1, 0, -1, 1, 1, -1} ;

/*###############-> Constraints <-###############*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

/*...... ! Code starts from here ! ......*/

vector < int > edge[N] ;
int in[N], out[N], par[N][20], dep[N], cur ;

void dfs(int s, int p = 0){
    par[s][0] = p ;
    dep[s] = 1 + dep[p] ;
    in[s] = ++cur ;
    for(int i = 1 ; i < 20 ; ++i)
        par[s][i] = par[par[s][i - 1]][i - 1] ;
    for(int i : edge[s]){
        if(i == p)continue ;
        dfs(i, s) ;
    }
    out[s] = ++cur ;
}

bool cmp(int a, int b){
    return dep[a] > dep[b] ;
}

bool ancestor(int x, int y){
    return in[x] <= in[y] and out[x] >= out[y] ;
}

int lca(int a, int b){
    if(dep[a] < dep[b])swap(a, b) ;
    int d = dep[a] - dep[b] ;
    for(int i = 19 ; i >= 0 ; --i)
        if(d >> i & 1)a = par[a][i] ;
    if(a == b)return a ;
    for(int i = 19 ; i >= 0 ; --i){
        if(par[a][i] != par[b][i]){
            a = par[a][i] ;
            b = par[b][i] ;
        }
    }
    return par[a][0] ;
}

int main() {
    // ios_base::sync_with_stdio(false) ;
    // cin.tie(NULL) ; cout.tie(NULL) ;
    int test = 1 , tc = 0 ;
    //Int(test) ;
    while (test--) {
        int n, m ; Int(n, m) ;
        for(int i = 1 ; i < n ; ++i){
            int x, y ;
            Int(x, y) ;
            edge[x].pb(y) ;
            edge[y].pb(x) ;
        }
        cur = 0 ;
        dfs(1) ;
        while(m--){
            int k ; Int(k) ;
            vi v ;
            for(int i = 0 ; i < k ; ++i){
                int x ; Int(x) ;
                v.pb(x) ;
            }
            sort(all(v), cmp) ;
            if(k == 1)puts("YES") ;
            else {
                int i = 1, ok = 1 ;
                cur = v[0] ;
                for(int i = 1 ; i < k ; ++i){
                    if(ancestor(v[i], cur))cur = v[i] ;
                    else {
                        int anc = lca(cur, v[i]) ;
                        if(dep[v[i]] - dep[anc] > 1){
                            ok = 0 ;
                            break ;
                        }
                        cur = anc ;
                    }
                }
                if(!ok)puts("NO") ;
                else puts("YES") ;
            }
        }
    }
    return 0 ;
}


/**
 *  “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
 *
 *  author  :   prodipdatta7
 *  created :   Thursday 26-March, 2020  10:41:56 PM
**/

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")

using namespace std ;
using namespace __gnu_pbds ;

#define     ll          long long
#define     ld          long double
#define     ull         unsigned long long
#define     pii         pair<int,int>
#define     pll         pair<ll,ll>
#define     vi          vector<int>
#define     vll         vector<ll>
#define     vvi         vector<vector<int>>
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     all(x)      x.begin() , x.end()
#define     rall(x)     x.rbegin() , x.rend()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     fread       freopen("input.txt","r",stdin)
#define     fwrite      freopen("output.txt","w",stdout)
#define     TN          typename

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

/*###############-> Input Section <-###############*/

template <TN T> inline void Int(T &a) {
    bool minus = false; a = 0; char ch = getchar();
    while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
    if (ch == '-') minus = true; else a = ch - '0';
    while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
    if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}

/*###############-> Debugger <-###############*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1} ;

/*###############-> Constraints <-###############*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

/*...... ! Code starts from here ! ......*/

vector < int > edge[N] ;
int in[N], out[N], par[N], dep[N], cur ;

void dfs(int s, int p = 0) {
    par[s] = p ;
    dep[s] = 1 + dep[p] ;
    in[s] = ++cur ;
    auto it = find(all(edge[s]), p) ;
    if(it != edge[s].end())edge[s].erase(it) ;
    for (int i : edge[s]) {
        dfs(i, s) ;
    }
    out[s] = ++cur ;
}

bool ancestor(int x, int y) {
    return in[x] <= in[y] and out[x] >= out[y] ;
}

int main() {
    // ios_base::sync_with_stdio(false) ;
    // cin.tie(NULL) ; cout.tie(NULL) ;
    int test = 1 , tc = 0 ;
    //Int(test) ;
    while (test--) {
        int n, m ; Int(n, m) ;
        for (int i = 1 ; i < n ; ++i) {
            int x, y ;
            Int(x, y) ;
            edge[x].pb(y) ;
            edge[y].pb(x) ;
        }
        cur = 0 ;
        dfs(1) ;
        par[1] = 1 ;
        while (m--) {
            int k ; Int(k) ;
            vi v(k) ;
            int deepestNode = 0, len = 0 ;
            for (int &i : v) {
                Int(i) ;
                i = par[i] ;
                if(dep[i] > len){
                    len = dep[i] ;
                    deepestNode = i ;
                }
            }
            int ok = 1 ;
            for (int i : v) {
                ok &= ancestor(i, deepestNode) ;
                if(!ok)break ;
            }
            if (!ok)puts("NO") ;
            else puts("YES") ;
        }
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int vis[N],elem[N];
int fa[N];
int k,tcnt,kk;
int dep[N];
void dfs(int x,int f){

    for(int v:g[x]){
        if(v==f) continue;
        fa[v] = x;
        dep[v] = dep[x]+1;
        dfs(v,x);
    }
}
void fandfs(int x){
    if(x==0||tcnt==kk) return;
    //if(x==1&&vis[1]==1) ++tcnt;
    if(vis[x]) ++tcnt;
    fandfs(fa[x]);
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }
    dep[1] = 1;
    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int chd = 0,maxdep=-1;
        kk = 0;
        rep(j,1,k){
            int tp;cin>>tp;
            //kk[j] = tp;
            if(!vis[fa[tp]]&&fa[tp]!=0){
                vis[fa[tp]] = 1;
                elem[++kk] = fa[tp];
                if(dep[fa[tp]]>maxdep){
                    chd = fa[tp];maxdep = dep[fa[tp]];
                }
            }
        }
        tcnt = 0;
        fandfs(chd);
        if(tcnt==kk) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
        rep(j,1,kk){
            vis[elem[j]] = 0;
        }

    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int f[N][20];
int k;
int dep[N],qu[N];
void dfs(int x,int ff){
    dep[x] = dep[ff]+1;
    rep(i,1,19){
        f[x][i] = f[f[x][i-1]][i-1];
    }
    for(int v:g[x]){
        if(v==ff) continue;
        f[v][0] = x;
        dfs(v,x);
    }
}
int lca(int a,int b){
    if(dep[a]<dep[b]){
        swap(a,b);
    }
    if(dep[a]>dep[b])
    {
        per(i,19,0){
            if(dep[f[a][i]]>=dep[b]){
                a = f[a][i];
            }
        }
    }
    if(a==b) return a;
    per(i,19,0){
        if(f[a][i]!=f[b][i]){
            a = f[a][i];b = f[b][i];
        }
    }

    return f[a][0];

}

int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }
    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int st,maxdep = 0;
        rep(j,1,k){
            cin>>qu[j];
            if(dep[qu[j]]>maxdep){
                maxdep = dep[qu[j]];
                st = qu[j];
            }
        }
        int fg = 0;
        rep(j,1,k){
            int lc = lca(st,qu[j]);
            int fg1 = 0;
            if(lc == qu[j]) continue;
            for(int v:g[lc]){
                if(v==qu[j]){
                    fg1=1;break;
                }
            }
            if(!fg1){
                fg=1;break;
            }
            // if(dep[qu[j]]-dep[lc]>1){
            //     fg=1;break;
            // }
        }

        if(!fg) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int vis[N],kk[N];
int fa[N];
int k,tcnt;

void dfs(int x,int f){
    for(int v:g[x]){
        if(v==f) continue;
        fa[v] = x;
        dfs(v,x);
    }
}
void fandfs(int x){
    if(x==0) return;
    if(x==1&&vis[1]==1) ++tcnt;
    for(int v:g[x]){
        if(v==fa[x]) continue;
        if(vis[v]) ++tcnt;
    }
    fandfs(fa[x]);
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }

    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int chd = 0;
        rep(j,1,k){
            int tp;cin>>tp;
            kk[j] = tp;
            vis[tp] = 1;
            chd = max(chd,tp);
        }
        tcnt = 0;
        fandfs(chd);
        if(tcnt==k) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
        rep(j,1,k){
            vis[kk[j]] = 0;
        }

    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int fa[N];
int k;
int qu[N];
int L[N],R[N],cnt;
void dfs(int x,int f){
    L[x] = ++cnt;
    for(int v:g[x]){
        if(v==f) continue;
        fa[v] = x;
        dfs(v,x);
    }
    R[x] = cnt;
}
bool cmp(int a,int b){
    return L[a]<L[b];
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }
    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        rep(j,1,k){
            cin>>qu[j];
            qu[j] = (fa[qu[j]]==0)?1:fa[qu[j]];
        }
        sort(qu+1,qu+k+1,cmp);
        int fg = 0,tl=0,tr=2e5+5;;

        rep(j,1,k){
            if(L[qu[j]]>=tl&&R[qu[j]]<=tr){
                tl = L[qu[j]];tr = R[qu[j]];
            }else{
                fg = 1;break;
            }
        }
        if(!fg) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';

    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int f[N][20];
int k;
int dep[N],qu[N];
void dfs(int x,int ff){
    dep[x] = dep[ff]+1;
    rep(i,1,19){
        f[x][i] = f[f[x][i-1]][i-1];
    }
    for(int v:g[x]){
        if(v==ff) continue;
        f[v][0] = x;
        dfs(v,x);
    }
}
int lca(int a,int b){
    if(dep[a]<dep[b]){
        swap(a,b);
    }
    if(dep[a]>dep[b])
    {
        per(i,19,0){
            if(dep[f[a][i]]>=dep[b]){
                a = f[a][i];
            }
        }
    }
    if(a==b) return a;
    per(i,19,0){
        if(f[a][i]!=f[b][i]){
            a = f[a][i];b = f[b][i];
        }
    }

    return f[a][0];

}

int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }
    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int st,maxdep = 0;
        rep(j,1,k){
            cin>>qu[j];
            if(dep[qu[j]]>maxdep){
                maxdep = dep[qu[j]];
                st = qu[j];
            }
        }
        int fg = 0;
        rep(j,1,k){
            int lc = lca(st,qu[j]);
            //int fg1 = 0;
            // for(int v:g[lc]){
            //     if(v==j){
            //         fg1=1;break;
            //     }
            // }
            if(dep[qu[j]]-dep[lc]>1){
                fg=1;break;
            }
        }

        if(!fg) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int vis[N],kk[N];
int fa[N];
int k,tcnt;

void dfs(int x,int f){
    for(int v:g[x]){
        if(v==f) continue;
        fa[v] = x;
        dfs(v,x);
    }
}
void fandfs(int x){
    if(x==0) return;
    if(x==1&&vis[1]==1) ++tcnt;
    for(int v:g[x]){
        if(v==fa[x]) continue;
        if(vis[v]) ++tcnt;
    }
    fandfs(fa[x]);
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }

    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int chd = 0;
        rep(j,1,k){
            int tp;cin>>tp;
            kk[j] = tp;
            vis[tp] = 1;
            chd = max(chd,tp);
        }
        tcnt = 0;
        fandfs(fa[chd]);
        if(tcnt==k) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
        rep(j,1,k){
            vis[kk[j]] = 0;
        }

    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int f[N][20];
int k;
int dep[N],qu[N];
void dfs(int x,int ff){
    dep[x] = dep[ff]+1;
    rep(i,1,19){
        f[x][i] = f[f[x][i-1]][i-1];
    }
    for(int v:g[x]){
        if(v==ff) continue;
        f[v][0] = x;
        dfs(v,x);
    }
}
int lca(int a,int b){
    if(dep[a]<dep[b]){
        swap(a,b);
    }
    if(dep[a]>dep[b])
    {
        per(i,19,1){
            if(dep[f[a][i]]>=dep[b]){
                a = f[a][i];
            }
        }
    }
    if(a==b) return a;
    per(i,19,1){
        if(f[a][i]!=f[b][i]){
            a = f[a][i];b = f[b][i];
        }
    }

    return f[a][0];

}
int getdis(int a,int b,int lc){
    return dep[a]+dep[b] - dep[lc]*2;
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }
    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int st,maxdep = 0;
        rep(j,1,k){
            cin>>qu[j];
            if(dep[qu[j]]>maxdep){
                maxdep = dep[qu[j]];
                st = qu[j];
            }
        }
        int fg = 0;
        rep(j,1,k){
            int lc = lca(st,j);
            int fg1 = 0;
            for(int v:g[lc]){
                if(v==j){
                    fg1=1;break;
                }
            }
            if(fg1){
                fg=1;break;
            }
        }

        if(!fg) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
    }

}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
#define pb push_back

using namespace  std;

const int N = 2e5+5;
vector<int> g[N];
int vis[N],kk[N];
int fa[N];
int k,tcnt;
int dep[N];
void dfs(int x,int f){

    for(int v:g[x]){
        if(v==f) continue;
        fa[v] = x;
        dep[v] = dep[x]+1;
        dfs(v,x);
    }
}
void fandfs(int x){
    if(x==0||tcnt==k) return;
    if(x==1&&vis[1]==1) ++tcnt;
    for(int v:g[x]){
        if(v==fa[x]) continue;
        if(vis[v]) ++tcnt;
    }
    fandfs(fa[x]);
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,n-1){
        int u,v;cin>>u>>v;
        g[u].push_back(v);g[v].push_back(u);
    }

    dfs(1,0);
    rep(i,1,m){
        cin>>k;
        int chd = 0,maxdep=-1;
        rep(j,1,k){
            int tp;cin>>tp;
            kk[j] = tp;
            vis[tp] = 1;
            if(dep[tp]>maxdep){
                chd = tp;maxdep = dep[tp];
            }
        }
        tcnt = 0;
        fandfs(chd);
        if(tcnt==k) cout<<"YES"<<'\n';
        else cout<<"NO"<<'\n';
        rep(j,1,k){
            vis[kk[j]] = 0;
        }

    }

}