import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

struct S {
    int node;
    int cost;
}

void main() {
    int n = readint();

    S[][int] adj;
    for (int i = 0; i < n - 1; i++) {
        auto abc = readints();
        int a = abc[0], b = abc[1], c = abc[2];
        adj[a] ~= S(b, c);
    }

    auto qk = readints();
    int q = qk[0], k = qk[1];
    for (int i = 0; i < q; i++) {
        auto xy = readints();
        int x = xy[0], y = xy[1];

        //         auto ans = d[x][k - 1] + d[k - 1][y];
        //        writeln(ans);
    }
}
