#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); rep(i,(k+d-1)/d){ auto pre = tot; tail += d; 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; }