#include using namespace std; template struct binary_indexed_tree{ int N; vector BIT; binary_indexed_tree(int N): N(N), BIT(N + 1, 0){ } void add(int i, T x){ i++; while (i <= N){ BIT[i] += x; i += i & -i; } } T sum(int i){ T ans = 0; while (i > 0){ ans += BIT[i]; i -= i & -i; } return ans; } T sum(int L, int R){ return sum(R) - sum(L); } }; int main(){ int N, K, Q; cin >> N >> K >> Q; vector L(K), R(K), C(K), H(K); for (int i = 0; i < K; i++){ cin >> L[i] >> R[i] >> C[i] >> H[i]; L[i]--; } vector I(Q), X(Q); for (int i = 0; i < Q; i++){ cin >> I[i] >> X[i]; I[i]--; X[i]--; } vector> add(N), sub(N + 1); for (int i = 0; i < K; i++){ add[L[i]].push_back(i); sub[R[i]].push_back(i); } vector> query(N); for (int i = 0; i < Q; i++){ query[I[i]].push_back(i); } binary_indexed_tree BIT(K); vector ans(Q); for (int i = 0; i < N; i++){ for (int j : add[i]){ BIT.add(j, H[j]); } for (int j : sub[i]){ BIT.add(j, -H[j]); } for (int j : query[i]){ if (BIT.sum(0, K) < X[j]){ ans[j] = -1; } else { int tv = K, fv = 0; while (tv - fv > 1){ int mid = (tv + fv) / 2; if (BIT.sum(0, mid) > X[j]){ tv = mid; } else { fv = mid; } } ans[j] = C[fv]; } } } for (int i = 0; i < Q; i++){ cout << ans[i] << endl; } }