import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] # B = BIT([0]*M) class BIT: #1-index def __init__(self,init_value): self.n = len(init_value) self.tree = [0]*(self.n+1) for i in range(1,self.n+1): x = init_value[i-1] while i <= self.n: self.tree[i] += x i += i & (-i) def add(self,i,x): while i <= self.n: self.tree[i] += x i += i & (-i) return def to_sum(self,i): res = 0 while i > 0: res += self.tree[i] i -= i & (-i) return res # get(i,i)でi番目を取得 def get(self, i, j): return self.to_sum(j)-self.to_sum(i-1) def lower_bound(self,x): # a_1+…+a_i >= x となる最小のi res = 0 r = 1 while r <= self.n: r <<= 1 while r: if res+r <= self.n and self.tree[res+r] < x: x -= self.tree[res+r] res += r r >>= 1 return res+1 def main(): # N: 横, K: 壁の種類, Q: クエリ N,K,Q = map(int,input().split()) wall_colors = [-1]*(N+1) # 何番目の壁で高さいくつが追加/消去されるか。 wall_start = [[] for _ in range(K+2)] wall_end = [[] for _ in range(K+2)] for i in range(K): L,R,C,H = map(int,input().split()) wall_start[L].append((i+1,H)) wall_end[R+1].append((i+1,H)) wall_colors[i+1] = C #print(wall_start) #print(wall_end) # queries[i]: i番目(1-index)の壁に対するクエリ queries = [[] for _ in range(N+1)] for i in range(Q): I,X = map(int,input().split()) queries[I].append((i,X)) ans = [-1]*Q # i番目(1-index)の壁の高さが今どうなっているか。 Tree = BIT([0]*K) for x in range(1,N+1): # i番目(1-index)の壁が、H伸びる。 for i,H in wall_start[x]: #print("start",i,H) Tree.add(i,H) # i番目(1-index)の壁が、H消える。 for i,H in wall_end[x]: #print("end",i,H) Tree.add(i,-H) # デバッグ用 # state = [] # for i in range(1,K+1): # state.append(Tree.get(i,i)) #print(x,state) for idx, height in queries[x]: #print("zenbu",Tree.to_sum(K), height) if Tree.to_sum(K) < height: continue ci = Tree.lower_bound(height) ans[idx] = wall_colors[ci] print(*ans,sep="\n") if __name__ == '__main__': main()