#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define FORLL(i, a, b) for (ll i = a, _b = b; i <= _b; ++i)
#define FORDLL(i, a, b) for (ll i = a, _b = b; i >= _b; --i)
#define all(x) x.begin(), x.end()
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__)
template<typename T>
void __print_one(const char *&s, const T &x)
{
while (*s == ' ') ++s;
const char *p = s;
int bal = 0;
while (*s)
{
if (*s == '(') ++bal;
else if (*s == ')') --bal;
else if (*s == ',' && bal == 0) break;
++s;
}
cerr.write(p, s - p) << " = " << x;
if (*s == ',')
{
++s;
cerr << " , ";
}
}
template<typename... Args>
void debug(const char *s, Args... args)
{
cerr << "[ ";
int dummy[] = { 0 , ( __print_one(s, args) , 0 )... };
(void)dummy;
cerr << " ]\n\n";
}
template<class X>
bool maximize(X &a, X b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
template<class X>
bool minimize(X &a, X b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
const int maxn = 5e5 + 3;
int n, q, h[maxn], tin[maxn], tour[maxn << 1][20], lg[maxn << 1], tdfs;
ll D[maxn], dist[maxn];
vector<pii> g[maxn];
// --------------------------------------------------------------------------------------------
void dfs_pre(int u, int p)
{
tin[u] = ++tdfs;
tour[tdfs][0] = u;
for (const auto &e : g[u])
{
if (e.fi == p) continue;
D[e.fi] = D[u] + e.se;
h[e.fi] = h[u] + 1;
dfs_pre(e.fi, u);
tour[++tdfs][0] = u;
}
}
#define MIN_H(x, y) (h[x] < h[y] ? x : y)
int lca(int u, int v)
{
u = tin[u]; v = tin[v];
if (u > v) swap(u, v);
int k = lg[v - u + 1];
return MIN_H(tour[u][k], tour[v - (1 << k) + 1][k]);
}
ll get_dist(int u, int v)
{
return D[u] + D[v] - 2 * D[lca(u, v)];
}
void solve()
{
cin >> n >> q;
FOR(i, 2, n)
{
int u, v, w; cin >> u >> v >> w;
if (u > v) swap(u, v);
g[u].push_back({v, w});
g[v].push_back({u, w});
}
dfs_pre(0, -1);
FOR(i, 2, tdfs)
lg[i] = lg[i >> 1] + 1;
FOR(j, 1, 19)
FOR(i, 1, tdfs - (1 << j) + 1)
tour[i][j] = MIN_H(tour[i][j - 1], tour[i + (1 << j - 1)][j - 1]);
while (q--)
{
vector<int> A, B;
int nA, nB; cin >> nA >> nB;
FOR(i, 1, nA)
{
int x; cin >> x;
A.push_back(x);
}
FOR(i, 1, nB)
{
int y; cin >> y;
B.push_back(y);
}
ll res = 1e18;
if (1ll * nA * nB <= ll(8e5))
{
for (int u : A)
for (int v : B)
{
res = min(res, get_dist(u, v));
}
}
else
{
priority_queue<pll, vector<pll>, greater<pll>> Q;
FOR(i, 0, n - 1)
dist[i] = ll(1e18);
for (int x : B)
{
Q.push({0ll, x});
dist[x] = 0;
}
while (Q.size())
{
ll w; int u; tie(w, u) = Q.top(); Q.pop();
if (w > dist[u]) continue;
for (const auto &e : g[u])
{
if (dist[e.fi] > w + e.se)
{
dist[e.fi] = w + e.se;
Q.push({dist[e.fi], e.fi});
}
}
}
for (int x : A)
{
res = min(res, dist[x]);
}
}
cout << res << '\n';
}
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define TASK "TEST"
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
freopen(TASK".OUT", "w", stdout);
}
solve();
return 0;
}