#include namespace { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic pop using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; constexpr long long INF = 1002003004005006007; ll op(ll x, ll y) { return min(x, y); } ll e() { return INF; } ll composition(ll f, ll g) { return f + g; } ll id() { return 0; } ll mapping(ll f, ll x) { return f + x; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k, q; cin >> n >> k >> q; struct Q { int l, r, c, h; }; vector builds(k); for(auto& [l, r, c, h]: builds) { cin >> l >> r >> c >> h; l--; } // qid, i, x vector> queries(q); rep(tt, q) { auto& [qid, i, x] = queries[tt]; qid = tt; cin >> i >> x; i--, x--; } sort(all(queries), [](const tuple& x, const tuple& y) { return get<1>(x) < get<1>(y); }); VI idx(n + 1); { int now = 0; rep(i, n) { while(now < q && get<1>(queries[now]) < i) now++; idx[i] = now; } idx[n] = q; } VL init_vec(q); rep(i, q) init_vec[i] = get<2>(queries[i]); lazy_segtree seg(init_vec); VI ans(q, -1); for(auto [l, r, c, h]: builds) { seg.apply(idx[l], idx[r], -h); while(true) { int i = seg.max_right(0, [](ll x) { return x >= 0; }); if (i == q) break; ans[get<0>(queries[i])] = c; seg.set(i, INF); } } rep(i, q) cout << ans[i] << '\n'; }