#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving csa rating

// Code below

const int N = 1e5 + 5, LOG = 29;

int n, Q, K;

vector<pair<int, llong> > tree[N];
vector<pair<int, int> > qs;

void inp() {
    cin >> n;
    int a, b;
    llong c;
    for (int i = 0; i < n - 1; i++) {
        cin >> a >> b >> c;
        tree[a].pb({b, c});
        tree[b].pb({a, c});
    }
    cin >> Q >> K;
    qs.resize(Q);
    for (auto &x : qs) {
        cin >> x.fi >> x.se;
    }
}

pair<int, llong> lift[N][LOG];
int height[N];

void calc(int v, int p = -1, llong e = 0ll, int h = 0) {
    lift[v][0] = {(p == -1 ? v : p), (p == -1 ? 0ll : e)};
    height[v] = h;
    for (int i = 1; i < LOG; i++) {
        lift[v][i] = {lift[lift[v][i - 1].fi][i - 1].fi, lift[v][i - 1].se + lift[lift[v][i - 1].fi][i - 1].se};
    }
    for (auto u: tree[v]) {
        if (u.fi == p) {
            continue;
        }
        calc(u.fi, v, u.se, h + 1);
    }
}

llong get(int a, int b) {
    llong ans = 0;
    int iA = LOG - 1, iB = LOG - 1, iC = LOG - 1;
    while (height[a] > height[b]) {
        if (height[lift[a][iA].fi] >= height[b]) {
            ans += lift[a][iA].se;
            a = lift[a][iA].fi;
        }
        --iA;
    }
    while (height[b] > height[a]) {
        if (height[lift[b][iB].fi] >= height[a]) {
            ans += lift[b][iB].se;
            b = lift[b][iB].fi;
        }
        --iB;
    }
    while (a != b && iC >= 0) {
        if (lift[a][iC].fi != lift[b][iC].fi) {
            ans += lift[a][iC].se;
            ans += lift[b][iC].se;
            a = lift[a][iC].fi;
            b = lift[b][iC].fi;
        }
        iC--;
    }
    if (iC < 0) {
        ans += lift[a][0].se;
        ans += lift[b][0].se;
        a = lift[a][0].fi;
    }
    if (a != K) {
        ans += 2 * get(a, K);
    }
    return ans;
}

void solve() {
    calc(K);
    for (auto x : qs) {
        cout << get(x.fi, x.se) << endl;
    }
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 60032