N = int(eval(input()))



AB = []

for n in range(N):

    AB.append(list(map(int,input().split())))



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



sumW = 0

for a in aaa:

    sumW += a[0]

    if sumW > a[1]:

        print('No')

        exit()



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



AB = []

for n in range(N):

    AB.append(list(map(int,input().split())))



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



sumW = 0

for a in aaa:

    sumW += a[0]

    if sumW > a[1]:

        print('No')

        exit()



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

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

-aaa = sorted(AB, key=lambda x: (x[1], x[0])) +aaa = sorted(AB, key=lambda x: (x[1]))