N=int(eval(input()))

AB=[]

for i in range(N):

  a,b=list(map(int, input().split()))

  AB.append([a,b])

AB=sorted(AB, key=lambda x: x[1])



addtime=0

nowtime=0

for i in range(N):

  a=AB[i][0]

  b=AB[i][1]

  nowtime+=a

  if nowtime>b:

    print("No")

    exit()

print("Yes")
N=int(eval(input()))



now=0

L=[]

for i in range(N):

    a,b=list(map(int, input().split()))

    L.append((a,b))



L=sorted(L, key=lambda x: x[1])



for i in range(N):

    t=L[i]

    a,b=t

    if now+a<=b:

        now+=a

    else:

        print("No")

        exit()



print("Yes")
N = int(eval(input()))
AB = []
for i in range(N):
    a, b = list(map(int, input().split()))
    AB.append([a, b])
AB = sorted(AB, key=lambda x: x[1])
addtime = 0
nowtime = 0
for i in range(N):
    a = AB[i][0]
    b = AB[i][1]
    nowtime += a
    if nowtime > b:
        print("No")
        exit()
print("Yes")

N = int(eval(input()))
now = 0
L = []
for i in range(N):
    a, b = list(map(int, input().split()))
    L.append((a, b))
L = sorted(L, key=lambda x: x[1])
for i in range(N):
    t = L[i]
    a, b = t
    if now + a <= b:
        now += a
    else:
        print("No")
        exit()
print("Yes")

-AB = [] +now = 0 +L = [] -    AB.append([a, b]) -AB = sorted(AB, key=lambda x: x[1]) -addtime = 0 -nowtime = 0 +    L.append((a, b)) +L = sorted(L, key=lambda x: x[1]) -    a = AB[i][0] -    b = AB[i][1] -    nowtime += a -    if nowtime > b: +    t = L[i] +    a, b = t +    if now + a <= b: +        now += a +    else: