#include<bits/stdc++.h>

using namespace std;

int main() {
    int N,M,Q;
    cin >> N >> M >> Q;

    vector<int> L(M), R(M);

    for(int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        L[i]--, R[i]--;
    }

    vector<vector<int>> train(N, vector<int>(N, 0));
    vector<vector<int>> train_cum(N+1, vector<int>(N+1, 0));

    for(int i = 0; i < M; i++) {
        train[L[i]][R[i]] += 1;
    }

    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            train_cum[i+1][j+1] = train_cum[i][j+1] + train_cum[i+1][j] - train_cum[i][j] + train[i][j];
        }
    }
    
    int p, q;
    vector<int> answer;

    for(int k = 0; k < Q; k++) {
        cin >> p >> q;

        answer.push_back(train_cum[q][q] - train_cum[p-1][q] - train_cum[q][p-1] + train_cum[p-1][p-1]);
    }

    for(auto i : answer) {
        cout << i << endl;
    }

	return 0;
}
#include <iostream>
#include <vector>
#include <queue>
#define INF 50000000000
struct vertex{
	std::vector<int> edge_to;
	std::vector<int> edge_cost;
	bool done;
	long long int mincost;
};
std::vector<vertex> G(100000);
void shortest_path(int v);
int V,E;
int r;
int main(void){
	std::cin>>V>>E>>r;
	for(int i=0;i<E;i++){
		int from,to,cost;
		std::cin>>from>>to>>cost;
		G[from].edge_to.push_back(to);
		G[from].edge_cost.push_back(cost);
//		G[to].edge_to.push_back(from);
//		G[to].edge_cost.push_back(cost);		
	}
	shortest_path(r);
	for(int i=0;i<V;i++){
		if(G[i].mincost!=INF){
			std::cout<<G[i].mincost<<std::endl;
		}else {
			std::cout<<"INF"<<std::endl;
		}	
	}
	return 0;
}
void shortest_path(int v){
	for(int i=0;i<V;i++){
		G[i].mincost=INF;
	}
	G[v].mincost=0;
	while(1){
		bool update=false;
		for(int i=0;i<V;i++){
			for(int j=0;j<G[i].edge_to.size();j++){
				if(G[ G[i].edge_to[j] ].mincost>G[i].mincost+G[i].edge_cost[j]){
					G[ G[i].edge_to[j] ].mincost=G[i].mincost+G[i].edge_cost[j];
					update=true;
				}
			}
		}
		if(!update){
			break;
		}
	}

}