#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
#define dur exit(0)
#define dur1 return(0)
const int N = 3e5 + 5;
struct dort {
int x, t, a, b;
};
dort a[N];
int val[N];
int main () {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, k, q;
cin >> n >> k >> q;
for (int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].t >> a[i].a >> a[i].b;
}
while ( q-- ) {
int l, r;
cin >> l >> r;
for (int i = 1; i <= k; ++i) {
val[i] = 1e9;
}
for (int i = 1; i <= n; ++i) {
if (a[i].a <= r and r <= a[i].b) {
val[a[i].t] = min (val[a[i].t], abs (l - a[i].x));
}
}
sort (val + 1, val + k + 1);
if (val[k] == 1e9) val[k] = -1;
cout << val[k] << "\n";
}
}
/*
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
2 1 3
1 1 1 4
1 1 2 6
1 3
1 5
1 7
1 1 1
100000000 1 1 1
1 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |