import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static ArrayList> graph = new ArrayList<>(); static int[][] parents; static int[] depths; static long[] weights; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); for (int i = 0; i < n; i++) { graph.add(new HashMap<>()); } for (int i = 0; i < n - 1; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); graph.get(a).put(b, c); graph.get(b).put(a, c); } parents = new int[18][n]; depths = new int[n]; weights = new long[n]; setDepths(0, 0, 0, 0); for (int i = 1; i < 18; i++) { for (int j = 0; j < n; j++) { parents[i][j] = parents[i - 1][parents[i - 1][j]]; } } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (q-- > 0) { int[] points = new int[3]; for (int i = 0; i < 3; i++) { points[i] = sc.nextInt(); } long ans = 0; for (int i = 0; i < 3; i++) { int lca = getLCA(points[i], points[(i + 1) % 3]); ans += weights[points[i]] + weights[points[(i + 1) % 3]] - weights[lca] * 2; } sb.append(ans / 2).append("\n"); } System.out.print(sb); } static void setDepths(int idx, int p, int d, long value) { parents[0][idx] = p; depths[idx] = d; weights[idx] = value; for (int x : graph.get(idx).keySet()) { if (x != p) { setDepths(x, idx, d + 1, value + graph.get(idx).get(x)); } } } static int getLCA(int a, int b) { if (depths[a] < depths[b]) { return getLCA(b, a); } for (int i = 17; i >= 0; i--) { if (depths[a] - depths[b] >= (1 << i)) { a = parents[i][a]; } } if (a == b) { return a; } for (int i = 17; i >= 0; i--) { if (parents[i][a] != parents[i][b]) { a = parents[i][a]; b = parents[i][b]; } } return parents[0][a]; } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }