#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FS first
#define SC second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(auto i:c)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&a){return accumulate(ALL(a),T());}
template<typename T>T max(vector<T>&a){return *max_element(ALL(a));}
template<typename T>T min(vector<T>&a){return *max_element(ALL(a));}
template<typename T>T max_index(vector<T>&a){return distance((a).begin(),max_element(ALL(a)));}
template<typename T>T min_index(vector<T>&a){return distance((a).begin(),min_element(ALL(a)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

template<typename T>
void dijkstra(const vector< vector<edge> >& G, vector<T>& d, int s)
{
   priority_queue<P<T,int>, vector<P<T,int>>, greater<P<T,int>> > que;
   fill(d.begin(), d.end(), INF);
   d[s] = 0;
   que.push(make_pair(0, s));
   while(!que.empty()) {
      T temp_cost = que.top().first;
      int from = que.top().second;
      que.pop();
      if (d[from] < temp_cost) continue;
      for (int i = 0; i < G[from].size(); i++) {
         edge e = G[from][i];
         if (d[e.to] > d[from] + e.cost) {
            d[e.to] = d[from] + e.cost;
            que.push(make_pair(d[e.to], e.to));
         }
      }
   }
}

signed main()
{
   int N; cin >> N;
   V<V<edge>> G(N);
   REP(i, N-1) {
      int a, b, c; cin >> a >> b >> c; a--; b--;
      G[a].PB((edge){ b, c });
      G[b].PB((edge){ a, c });
   }
   int Q, K; cin >> Q >> K; K--;
   V<int> x(Q), y(Q);
   REP(i, Q) {
      cin >> x[i] >> y[i]; x[i]--; y[i]--;
   }

   V<int> d(N);
   dijkstra(G, d, K);
   REP(i, Q) {
      cout << d[x[i]] + d[y[i]] << endl;
   }

   return 0;
}


Measured memory_bytes: 12656