import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static List> graph = new ArrayList<>(); static int[][] parents; static int[] depths; static long[] lengths; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < n + k; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < n - 1; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; int c = sc.nextInt(); graph.get(a).add(new Path(b, c)); graph.get(b).add(new Path(a, c)); } parents = new int[20][n]; depths = new int[n]; lengths = new long[n]; setDepth(0, 0, 0, 0); for (int i = 1; i < 20; i++) { for (int j = 0; j < n; j++) { parents[i][j] = parents[i - 1][parents[i - 1][j]]; } } int[] prices = new int[k]; for (int i = 0; i < k; i++) { int m = sc.nextInt(); prices[i] = sc.nextInt(); while (m-- > 0) { int a = sc.nextInt() - 1; graph.get(n + i).add(new Path(a, 0)); graph.get(a).add(new Path(n + i, prices[i])); } } PriorityQueue queue = new PriorityQueue<>(); long[][] costs = new long[k][n + k]; for (int i = 0; i < k; i++) { Arrays.fill(costs[i], Long.MAX_VALUE); queue.add(new Path(n + i, 0)); while (queue.size() > 0) { Path p = queue.poll(); if (costs[i][p.idx] <= p.value) { continue; } costs[i][p.idx] = p.value; for (Path x : graph.get(p.idx)) { queue.add(new Path(x.idx, p.value + x.value)); } } } int q = sc.nextInt(); String result = IntStream.range(0, q).mapToObj(x -> { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; long ans = lengths[a] + lengths[b] - lengths[getLCA(a, b)] * 2; for (int i = 0; i < k; i++) { ans = Math.min(ans, costs[i][a] + costs[i][b] + prices[i]); } return String.valueOf(ans); }).collect(Collectors.joining("\n")); System.out.println(result); } static void setDepth(int idx, int p, int d, long v) { parents[0][idx] = p; depths[idx] = d; lengths[idx] = v; for (Path x : graph.get(idx)) { if (x.idx != p) { setDepth(x.idx, idx, d + 1, v + x.value); } } } static int getLCA(int a, int b) { if (depths[a] < depths[b]) { return getLCA(b, a); } for (int i = 19; i >= 0; i--) { if (depths[a] - depths[b] >= (1 << i)) { a = parents[i][a]; } } if (a == b) { return a; } for (int i = 19; i >= 0; i--) { if (parents[i][a] != parents[i][b]) { a = parents[i][a]; b = parents[i][b]; } } return parents[0][a]; } static class Path implements Comparable { int idx; long value; public Path(int idx, long value) { this.idx = idx; this.value = value; } public int compareTo(Path another) { return Long.compare(value, another.value); } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }