#include <bits/stdc++.h>
using namespace std;
const int LOG = 17;
const int MAX = 100007;
vector<int> G[MAX];
int up[MAX][LOG];
int tin[MAX];
int tout[MAX];
int timer = 0;
void dfs(int v, int p)
{
tin[v] = timer ++;
up[v][0] = p;
for(int i = 1; i < LOG; i++)
{
up[v][i] = up[up[v][i - 1]][i - 1];
}
for(int to: G[v])
{
if (to == p) continue;
dfs(to , v);
}
tout[v] = timer ++;
}
bool upper(int a, int b)
{
return tin[a] <= tin[b] && tout[a] >= tout[b];
}
int lca(int a , int b)
{
if (upper(a , b)) return a;
if (upper(b , a)) return b;
for(int i = LOG - 1; i >= 0; i--)
{
if (!upper(up[a][i] , b))
a = up[a][i];
}
return up[a][0];
}
bool liesOnPath(int a , int b, int x)
{
int c = lca(a , b);
if (upper(c , x) && (upper(x , a) || upper(x , b))) return 1;
return 0;
}
int main()
{
int n , m;
cin >> n >> m;
for(int i = 0; i < n - 1; i++)
{
int a , b;
cin >> a >> b;
-- a; -- b;
G[a].push_back(b);
G[b].push_back(a);
}
dfs(0,0);
while(m--)
{
int l;
cin >> l;
vector<int> A;
for(int j = 0; j < l; j++)
{
int x;
cin >> x;
-- x;
A.push_back(x);
}
if (l == 1)
{
cout << "Tak" << endl;
continue;
}
int a = A[0];
int b = A[1];
bool ok = 1;
for(int i = 2; i < l; i++)
{
if (liesOnPath(a, b, A[i])) continue;
if (liesOnPath(a, A[i] , b))
{
b = A[i];
continue;
}
if (liesOnPath(b, A[i], a))
{
a = A[i];
continue;
}
ok = 0;
break;
}
if (ok) cout << "Tak" << endl;
else cout << "Ni" << endl;
}
return 0;
}