#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct DoublingLowestCommonAncestor {
  const int LOG;
  vector< int > dep;
  const G &g;
  vector< vector< int > > table;

  DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - __builtin_clz(g.size())) {
    table.assign(LOG, vector< int >(g.size(), -1));
  }

  void dfs(int idx, int par, int d) {
    table[0][idx] = par;
    dep[idx] = d;
    for(auto &to : g[idx]) {
      if(to != par) dfs(to, idx, d + 1);
    }
  }

  void build() {
    dfs(0, -1, 0);
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
	if(table[k][i] == -1) table[k + 1][i] = -1;
	else table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }

  int query(int u, int v) {
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = LOG - 1; i >= 0; i--) {
      if(((dep[v] - dep[u]) >> i) & 1) v = table[i][v];
    }
    if(u == v) return u;
    for(int i = LOG - 1; i >= 0; i--) {
      if(table[i][u] != table[i][v]) {
	u = table[i][u];
	v = table[i][v];
      }
    }
    return table[0][u];
  }
};

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


int main(){
  int N;
  cin >> N;
  UnWeightedGraph g(N);
  WeightedGraph<ll> gw(N);
  ll a,b,c;
  rep(i,N-1){
    cin >> a>> b>>c;
    a--;b--;
    g[a].emplace_back(b);
    gw[a].emplace_back(b,c);
    gw[b].emplace_back(a,c);
  }


  int Q,K;
  cin >> Q >> K;
  K--;
  vector<ll> cost;
  cost = dijkstra(gw,K);
  //rep(i,N) cout << cost[i] << endl;
  DoublingLowestCommonAncestor<UnWeightedGraph> lca(g);
  lca.build();
  ll kd=lca.dep[K];
  ll x,y;
  while(Q--){
    cin >> x >> y;
    x--;y--;
    ll xa=lca.query(x,y);
    /*if((lca.query(x,y)==lca.query(x,K) || lca.query(x,y)==lca.query(y,K))&& lca.dep[x]>=kd && lca.dep[y]>=kd){
      cout << cost[x]+cost[y] << endl;
    }
    else{
      cout << cost[x]+cost[y]-cost[xa]*2 + min(min(cost[x], cost[y]),cost[xa])*2 << endl;
    }*/
    cout << cost[x]+cost[y] << endl;
  }

  return 0;

}


Measured memory_bytes: 25080