#include <bits/stdc++.h>
using namespace std;

#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define TEN(n) ((ll)(1e##n))
#define fst first
#define snd second

using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class A,class B>bool amax(A&a,const B&b){return b>a?a=b,1:0;}
template<class A,class B>bool amin(A&a,const B&b){return b<a?a=b,1:0;}
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}

struct inout {
  static const long long ibufl = 1 << 25;
  static const long long obufl = 1 << 25;
  char in_buf[ibufl], out_buf[obufl], *inf, *ouf;
  void init() {
    fread(in_buf, 1, ibufl, stdin);
    inf = in_buf;
    ouf = out_buf;
  }
  inout &operator>>(long long &a) {
    long long fh = 1;
    while (!(isdigit(*inf) || *inf == '-')) ++inf;
    if (*inf == '-') fh = -1, ++inf;
    a = 0;
    while (isdigit(*inf)) {
      a = a * 10 + *inf - '0';
      ++inf;
    }
    a *= fh;
    return *this;
  }
  void writeint(long long x) {
    if (x / 10) writeint(x / 10);
    *ouf = x % 10 + '0';
    ++ouf;
  }
  inout &operator<<(long long a) {

    if (a < 0) {
      *ouf = '-';
      ++ouf;
      a = -a;
    }
    writeint(a);
    return *this;
  }
  static const long long sz = 7;
  inout &operator<<(char a) {
    *ouf = a;
    ++ouf;
    return *this;
  }
  inout &operator<<(char *a) {
    while (*a) {
      *ouf = *a;
      ++ouf;
      ++a;
    }
    return *this;
  }
  void out() { fwrite(out_buf, 1, ouf - out_buf, stdout); }
};
inout io;

using Weight = int;
struct Edge {
  int dst;
  Weight weight;
  Edge() : dst(0), weight(0) {}
  Edge(int d, Weight w = 1) : dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

vector<Edge> G[100005];
ll dist[100005];

void dfs(int cur, int pre) {
  for (const auto &nex : G[cur]) {
    if (nex.dst != pre) {
      dist[nex.dst] = dist[cur] + nex.weight;
      dfs(nex.dst, cur);
    }
  };
}

void Main() {
  ll n;
  io.init();
  io >> n;
  rep(i, n - 1) {
    ll u, v, w;
    io >> u >> v >> w;
    G[u].emplace_back(v, w);
    G[v].emplace_back(u, w);
  }

  ll q, k;
  io >> q >> k;

  dfs(k, -1);

  while (q--) {
    ll u, v;
    io >> u >> v;
    io << dist[u] + dist[v] << '\n';
  }
  io.out();
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
  return 0;
}

Measured memory_bytes: 21760