// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<queue>

using namespace std;

#define INF 9e18

const int maxn = 4e5 + 10;

struct road{

	int v;

	int to;

	int next;

}r[maxn];

long long dis[maxn];

int head[maxn],cnt;

bool vis[maxn];

void inti(){

	memset(head, -1, sizeof(head));

	for(int i = 0; i < maxn; ++i){

		dis[i] = INF;

	}

	memset(vis, false, sizeof(vis));

	cnt = 0;

}

void build(long long s, long long e, long long w){

	r[cnt].v = w;

	r[cnt].to = e;

	r[cnt].next = head[s];

	head[s] = cnt++;

}

void spfa(long long s){

	queue<int>q;

	int end, i, top;

	q.push(s);

	vis[s] = true;

	dis[s] = 0;

	while(!q.empty()){

		top = q.front();

		q.pop();

		vis[top] = false;

		for(i = head[top]; i != -1; i = r[i].next){

			end = r[i].to;

			if(dis[end] > dis[top] + r[i].v){

				dis[end] = dis[top] + r[i].v;

				if(!vis[end]){

					q.push(end);

					vis[end] = true;

				}

			}

		}

	}

}

int main()

{

	long long n, s, e, w, q, k, i, a, b;

	scanf("%lld",&n);

	inti();

	for(i = 1; i < n; ++i){

		scanf("%lld %lld %lld", &s, &e, &w);

		build(s, e, w);

		build(e, s, w);

	}

	scanf("%lld %lld", &q, &k);

	spfa(k);

	for(i = 1; i <= q; ++i){

		scanf("%lld %lld", &a, &b);

		//cout << dis[a] << endl;

		printf("%lld\n",dis[a] + dis[b]);

	}

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define sz(v)   ((int)(v).size())

#define  all(v)    ((v).begin()),((v).end())

#define  allr(v)    ((v).rbegin()),((v).rend())

#define   pb         push_back

#define   mp         make_pair

#define   mt         make_tuple

#define   Y            imag()

#define   X            real()

#define    clr(v,d)      memset( v, d ,sizeof(v))

#define   angle(n)      atan2((n.imag()),(n.real()))

#define   vec(a,b)       ((b)-(a))

//#define   length(a)      hypot( (a.imag()),(a.real()) )

#define   normalize(a)      (a)/(length(a))

#define    dp(a,b)          (((conj(a))*(b)).real())

//#define    cp(a,b)          (((conj(a))*(b)).imag())

#define    lengthsqrt(a)       dp(a,a)

#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))

#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)

#define    reflection0(m,v)         (conj((v)/(m))*(m))

#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0

//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )

#define     point                    complex<double>

#define outfile freopen("out.out", "w", stdout);

#define infile  freopen("in.in", "r", stdin);

#define PI acos(-1)

typedef  long long     ll ;

typedef  unsigned long long ull;

const double eps= (1e-9);

using namespace std;

int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}

ll setBit1(ll num, int idx) {return num | (1ll<<idx);}

ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

ll flipBit(int num, int idx) {return num ^ (1<<idx);}

void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

const int N=100009;

ll dist[N];

vector< vector< pair<int,int> > > v(N);

bool vis[N];

void dfs(int no,int p,ll co)

{

    dist[no]=co;

    vis[no]=1;

    for(int i=0;i<sz(v[no]);i++)

    {

        int nw=v[no][i].first;

        int we=v[no][i].second;

        if(vis[nw])

            continue;

        dfs(nw,no,co+we);

    }

}

int main()

{

    int n;

    cin>>n;

    for(int i=0;i<n-1;i++)

    {

        int a,b,c;

        cin>>a>>b>>c;

        v[a].pb(mp(b,c));

        v[b].pb(mp(a,c));

    }

    int q,k;

    cin>>q>>k;

    dfs(k,0,0);

    while(q--)

    {

        int fr,to;

        cin>>fr>>to;

        cout<<dist[fr]+dist[to]<<endl;

    }

}






// Fastest known solution for this problem: