// Slower C++ solution:
#include <bits/stdc++.h>



#define mod 1000000007

#define REP(i, n) for (int i = 0; i < n; i++)



using namespace std;



using ll = long long;

const int limit = 100010;

using edge = struct {int to; ll cost;};

vector<edge> tree[limit];

ll depth[limit];



/*long C(long n, long r){

    if(n < r) return 0;

    long p[n+1][n+1];

    p[0][0] = 1;

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

        p[i][0] = 1;

        p[i][i] = 1;

        for(int j = 1; j <= i-1; j++){

            p[i][j] = p[i-1][j] + p[i-1][j-1];

        }

    }

    return p[n][r];

}*/



long long gcd(long long a, long long b){

    if(a < b) swap(a, b);

    if(a % b == 0) {

        return b;

    }

    else{

        return gcd(b, a % b);

    }

}



long long lcm(long long a, long long b){

    return (max(a, b) / gcd(a, b)) * min(a, b);

}

 

void dfs(int v, int p, ll d){

    depth[v] = d;

    for(auto &e : tree[v]){

        if (e.to == p) continue;

        dfs(e.to, v, d + e.cost);

    }

}



void solve() {

    int N;

    cin >> N;

    

    REP(i, N-1){

        int a, b, c;

        cin >> a >> b >> c;

        tree[a].push_back({b, c});

        tree[b].push_back({a, c});

    }



    int Q, K;

    cin >> Q >> K;

    int x[Q], y[Q];

    dfs(K, -1, 0);

    REP(i, Q) {

        cin >> x[i] >> y[i];

    }

    REP(i, Q){

        cout << depth[x[i]] + depth[y[i]] << endl;

    }

}

 

int main() {

    solve();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.464565559480983x):
#include <bits/stdc++.h>

using namespace std;



#define rep(i, n) for (int i = 0; i < n; ++i)

#define ALL(a) (a).begin(), (a).end()

#define rALL(a) (a).rbegin(), (a).rend()

#define SZ(x) ((int)(x).size())

using ll = long long;

using P = pair<int, int>;

using llP = pair<ll, ll>;

using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};

const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};

const int INF = 1 << 29;

const ll INF64 = 1ll << 62;

const int mod = 1000000007;

//const int mod = 998244353;



template <class T>inline bool chmin(T &a, const T b)

{

  if (a > b)

  {

    a = b;

    return true;

  }

  return false;

}

template <class T>inline bool chmax(T &a, const T b)

{

  if (a < b)

  {

    a = b;

    return true;

  }

  return false;

}

template <class T>inline void line_out(const vector<T> vec) {

  int n = SZ(vec);

  rep(i, n) {

    cout << vec[i];

    if(i < n-1) cout << " ";

  }

  cout << endl;

  return;

}



struct mint

{

  ll x; // typedef long long ll;

  mint(ll x = 0) : x((x % mod + mod) % mod) {}

  mint operator-() const { return mint(-x); }

  mint &operator+=(const mint a)

  {

    if ((x += a.x) >= mod)

      x -= mod;

    return *this;

  }

  mint &operator-=(const mint a)

  {

    if ((x += mod - a.x) >= mod)

      x -= mod;

    return *this;

  }

  mint &operator*=(const mint a)

  {

    (x *= a.x) %= mod;

    return *this;

  }

  mint operator+(const mint a) const

  {

    mint res(*this);

    return res += a;

  }

  mint operator-(const mint a) const

  {

    mint res(*this);

    return res -= a;

  }

  mint &operator++()

  {

    if ((x += 1) >= mod)

      x -= mod;

    return *this;

  }

  mint &operator--()

  {

    if ((x += mod - 1) >= mod)

      x -= mod;

    return *this;

  }

  mint operator*(const mint a) const

  {

    mint res(*this);

    return res *= a;

  }

  mint pow(ll t) const

  {

    if (!t)

      return 1;

    mint a = pow(t >> 1);

    a *= a;

    if (t & 1)

      a *= *this;

    return a;

  }



  // for prime mod

  mint inv() const

  {

    return pow(mod - 2);

  }

  mint &operator/=(const mint a)

  {

    return (*this) *= a.inv();

  }

  mint operator/(const mint a) const

  {

    mint res(*this);

    return res /= a;

  }

};



struct edge{int to; ll cost;};



int main()

{

  int n; cin >> n;

  vector<vector<edge>> g(n+1);

  rep(i, n-1) {

    int a, b;

    ll c;

    cin >> a >> b >> c;

    edge x = {b, c};

    edge y = {a, c};

    g[a].push_back(x);

    g[b].push_back(y);

  }

  int q, k; cin >> q >> k;

  vector<int> x(q), y(q);

  rep(i, q) cin >> x[i] >> y[i];

  vector<ll> dist(n+1, INF64);

  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;



  dist[k] = 0;

  pq.push(make_pair(0ll, k));

  while(!pq.empty()) {

    auto p = pq.top(); pq.pop();

    int u = p.second;

    if(dist[u] < p.first) continue;

    for(auto next : g[u]) {

      int v = next.to;

      if(chmin(dist[v], dist[u]+next.cost)) pq.push(make_pair(dist[v], v));

    }

  }

  rep(i, q) {

    cout << dist[x[i]] + dist[y[i]] << endl;

  }

}