
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int cnt[550][550];
ll sum[110*5][110*5];

int main(){cout<<fixed<<setprecision(10);
		   //O(m+nq)
           int n,m,Q;
           cin>>n>>m>>Q;
           int r,l;
           rep(i,0,m){
             cin>>l>>r;
             
             cnt[l][r]++;
           }
           rep(i,1,n+1){
            rep(j,1,n+1){
              sum[i][j]=sum[i][j-1]+cnt[i][j];
              //cout<<sum[i][j]<<" ";
            }
            // cout<<endl;
           }
           int p,q;
           ll ans;
           rep(i,0,Q){
             cin>>p>>q;
             ans=0;
             rep(j,p,n+1){
              ans+=sum[j][q]; 
               
             }
             cout<<ans<<endl;
           }
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

const int MOD = 1e9+7;
const int INF = 1001001001;
const ll llINF = 1e18+9;
vector<pii> edge[100010];


int main(){
    int N;
    cin >> N;
    rep(i, 0, N-1){
        int a, b, c;
        cin >> a >> b >> c;
        edge[a-1].push_back(mp(b-1, c));
        edge[b-1].push_back(mp(a-1, c));
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    vector<ll> dist(N, llINF);
    dist[K] = 0;
    queue<pair<int, ll>> q;
    q.push(mp(K, 0));
    while (!q.empty()){
        int now = q.front().first;
        ll nowd = q.front().second;
        q.pop();
        for (auto x:edge[now]){
            int fol = x.first;
            ll d = x.second;
            ll nextd = nowd+d;
            if (dist[fol] < nextd) continue;
            dist[fol] = nextd;
            q.push({fol, nextd});
        }
    }
    rep(i ,0 , Q){
        int x, y;
        cin >> x >> y;
        --x, --y;
        ll ans = dist[x] + dist[y];
        cout << ans << endl;
    }
}