#pragma comment(linker, "/stack:640000000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
//#include <unordered_map>
/// unordered map only when c++ 11 is ticked :p
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const double EPS = 1e-9;
const double PI=acos(-1.0);

#define    READ(f)       freopen(f, "r", stdin)
#define    WRITE(f)      freopen(f, "w", stdout)

#define    INF           999999999999999
#define    pii           pair<int, int>
#define    pdd           pair<double, double>
#define    pll           pair<long long int, long long int>
#define    ii            long long int
#define    uii           unsigned long long int
#define    ui            unsigned int
#define    bitCheck(a,k) ((bool)(a&(1<<(k))))
#define    bitOff(a,k)   (a&(~(1<<(k))))
#define    bitOn(a,k)    (a|(1<<(k)))
#define    bitFlip(a,k)  (a^(1<<(k)))
#define    iseq(a,b)     (fabs(a-b)<EPS)

template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); }
template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); }
template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); }
template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;}
template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }


///******************DELETE****************

#ifdef rafiul41
     #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#else
    #define debug(args...)  // Just strip off all debug tokens
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;

int strToint(string x)
{
    stringstream ss(x);
    int i;
    ss>>i;
    return i; /// this int does not have any leading zeros !!!
}
///**************************************************

/// node structure is needed for the sorting in priority queue in the dijkstar's algo !!! :3
struct node
{
    int u,w;
    node(){};
    node(int a,int b)
    {
        u=a;w=b;
    }
    bool operator <(const node&p)const
    {
        return w>p.w;
    }
};

vector<int> vec[100005],cost[100005];
ii d[100005];

void dij(int src)
{
    priority_queue <node> pq;
    pq.push(node(src,0));
    d[src]=0;
    while(!pq.empty())
    {
        node uu=pq.top();
        int u=uu.u;
        pq.pop();
        int l=vec[u].size();
        for(int i=0;i<l;i++)
        {
            int v=vec[u][i];
            if(d[v]>d[u]+cost[u][i])
            {
                d[v]=d[u]+cost[u][i];
                pq.push(node(v,d[v]));
            }
        }
    }
}

int main()
{
#ifdef rafiul41
//
//    READ("in.txt");
//    WRITE("out.txt");

#endif // rafiul41
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        d[i]=999999999999999;
    }
    for(int i=0;i<n-1;i++)
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        vec[a].push_back(b);
        vec[b].push_back(a);
        cost[a].push_back(c);
        cost[b].push_back(c);
    }
    int q,k;
    scanf("%d %d",&q,&k);
    dij(k);
//    for(int i=1;i<=n;i++)
//    {
//        debug(d[i])
//    }
    for(int i=0;i<q;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        ii ans=d[x]+d[y];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 13936