#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> k >> q; vector a(k); rep(i,k){ cin >> a[i].l >> a[i].r >> a[i].c >> a[i].h; a[i].l--; } vector ans(q,-1); vector b(q); rep(i,q){ cin >> b[i].I >> b[i].x; b[i].I--; } ll tail = 0; vector tot(n+1,0), imos(n+1,0); auto pre = tot; rep(i,k){ if(i*d>=k) break; pre = tot; tail += d; rep(j,n+1) imos[j] = 0; for(ll j=i*d;j0 || tot[itr]=b[j].x){ ans[j] = a[p].c; break; } } } } } rep(i,q) cout << ans[i] << '\n'; return 0; }