// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;

alias Pair = Tuple!(int, "to", int, "cost");

int n, q, k;
Pair[][] adj;

void main() {
    scan(n);
    adj = new Pair[][](n, 0);

    int ai, bi, ci;

    foreach (i ; 0 .. n - 1) {
        scan(ai, bi, ci);
        ai--; bi--;
        adj[ai] ~= Pair(bi, ci);
        adj[bi] ~= Pair(ai, ci);
    }

    scan(q, k);
    k--;

    auto d = new long[](n);

    void dfs(int u, int p, long c) {
        d[u] = c;

        foreach (v ; adj[u]) {
            if (v.to == p) continue;
            dfs(v.to, u, c + v.cost);
        }
    }

    dfs(k, -1, 0);

    int xi, yi;

    while (q--) {
        scan(xi, yi);
        xi--; yi--;

        long ans = d[xi] + d[yi];
        writeln(ans);
    }
}

long lcm(long a, long b) {
    return a / gcd(a, b) * b;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}