#include<iostream>
#include<vector>
using namespace std;
int main(){
int n,q,k;
cin >> n >> k >> q;
vector<int> x(n);
vector<int> t(n);
vector<int> a(n);
vector<int> b(n);
for (int i=0;i<n;i++) cin >> x[i] >> t[i] >> a[i] >> b[i];
for (int i=0;i<q;i++){
int l,y;
cin >> l >> y;
vector<unsigned int> best(k, -1);
for (int j=0;j<n;j++){
if (y < a[j] || y > b[j]) continue;
if (abs(l -x[j]) < best[t[j] - 1]) best[t[j] - 1] = abs(l -x[j]);
}
unsigned int worst = 0;
for (int j=0;j<k;j++) if (best[j] > worst) worst = best[j];
cout << (int) worst << endl;
}
return 0;
}