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

using namespace std;

//#include <boost/multiprecision/cpp_int.hpp>

//using multiInt = boost::multiprecision::cpp_int;



using ll = long long int;

using ld = long double;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

template<typename Q_temp>

using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;



const int INF = (int) 1e9;

const ll LINF = (ll) 4e18;

const ll MOD = (ll) (1e9 + 7);

const double PI = acos(-1.0);



#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)

#define rep(i,n) REP(i, 0, n)

#define MP make_pair

#define MT make_tuple

#define YES(n) cout << ((n) ? "YES" : "NO") << endl

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define all(v) v.begin(), v.end()

#define NP(v) next_permutation(all(v))

#define dbg(x_) cerr << #x_ << ":" << x_ << endl;

#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;

#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};

vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};



inline ll CEIL(ll a, ll b) {

    return (a + b - 1) / b;

}



void finish() {

    cout << -1 << endl;

    exit(0);

}



//------------------------------------------------------

const ll MAX_V = 200010;



class dijkstra {

public:



    struct edge {

        ll to;

        ll cost;

    };



    vector<edge> E[MAX_V];

    ll d[MAX_V];



    void calc(ll s) {

        priority_queue <pll, vector<pll>, greater<pll> > que;

        rep(i, MAX_V) d[i] = LINF;

        que.emplace(0LL, s);

        d[s] = 0LL;

        while (!que.empty()) {

            pll p = que.top();

            que.pop();

            ll v = p.second;

            if (d[v] < p.first) continue;



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

                if (d[e.to] > d[v] + e.cost) {

                    d[e.to] = d[v] + e.cost;

                    que.emplace(d[e.to], e.to);

                }

            }

        }

    }

};



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    dijkstra ds;

    int n;

    cin >> n;



    rep(i, n - 1) {

        ll a, b, c;

        cin >> a >> b >> c;

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

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

    }



    int q, k;

    cin >> q >> k;

    ds.calc(k);



    rep(i, q) {

        int x, y;

        cin >> x >> y;

        cout << ds.d[x] + ds.d[y] << endl;

    }





    return 0;

}


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

using namespace std;

typedef long long ll;

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



vector<pair<int, int>> gra[100010]; //

ll dist[100010];                    //



void dfs(ll x, ll y)

{

  for (const auto &it : gra[x])

  {

    ll s = it.first, len = it.second;

    if (dist[s] != -1)

      continue;

    dist[s] = y + len;

    dfs(s, dist[s]);

  }

}



int main()

{

  ll n, q, k;

  cin >> n;

  rep(i, n - 1)

  {

    ll a, b, c;

    cin >> a >> b >> c;

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

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

  }

  cin >> q >> k;

  rep(i, 100010) dist[i] = -1;

  dist[k] = 0; //

  dfs(k, 0);

  rep(i, q)

  {

    ll x, y;

    cin >> x >> y;

    ll ans = dist[x] + dist[y];

    cout << ans << endl;

  }

}