#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int, int>> graph[100001];
int ans[100001];
signed main() {
    //Ввод графа и вершины start.
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		--a, --b;
		graph[a].push_back({b, c});
		graph[b].push_back({a, c});
	}
	int Q, K;
	cin >> Q >> K;
    for (int i = 0; i < n; i++) {
        ans[i] = LONG_MAX;
    }
    int start = K - 1;
    ans[start] = 0;

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;

    q.push({0, start});

    while (!q.empty()) {
        pair<int, int> c = q.top();
        q.pop();

        int dst = c.first, v = c.second;

        if (ans[v] < dst) {
            continue;
        }

        for (pair<int, int> e: graph[v]) {
            int u = e.first, len_vu = e.second;

            int n_dst = dst + len_vu;
            if (n_dst < ans[u]) {
                ans[u] = n_dst;
                q.push({n_dst, u});
            }
        }
    }
    for (int i = 1; i <= Q; i++) {
    	int u, v;
    	cin >> u >> v;
    	u--; v--;
    	cout << ans[u] + ans[v] << '\n';
    }
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M, Q, sum[510][510], lr[510][510];

int main(int argc, char **argv)
{
	cin >> N >> M >> Q;
	REP(i, M)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		++lr[l][r];
	}

	REP(i, N)REP(j, N)
	{
		sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + lr[i][j];
	}

	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		std::cout << sum[r+1][r+1] - sum[r+1][l] - sum[l][r+1] + sum[l][l] << std::endl;
	}
}
