ABs = []



N = int(eval(input()))

for i in range(N):

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



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



sum = 0

for pair in ABs:

    sum += pair[0]

    if sum > pair[1]:

        print('No')

        exit()

print('Yes')
ABs = []



N = int(eval(input()))

for i in range(N):

    ABs.append(tuple(map(int,input().split())))



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



sum = 0

for A, B in ABs:

    sum += A

    if sum > B:

        print('No')

        exit()

print('Yes')
ABs = []
N = int(eval(input()))
for i in range(N):
    ABs.append(list(map(int, input().split())))
ABs = sorted(ABs, key=lambda x: x[1])
sum = 0
for pair in ABs:
    sum += pair[0]
    if sum > pair[1]:
        print("No")
        exit()
print("Yes")

ABs = []
N = int(eval(input()))
for i in range(N):
    ABs.append(tuple(map(int, input().split())))
ABs = sorted(ABs, key=lambda x: x[1])
sum = 0
for A, B in ABs:
    sum += A
    if sum > B:
        print("No")
        exit()
print("Yes")

-    ABs.append(list(map(int, input().split()))) +    ABs.append(tuple(map(int, input().split()))) -for pair in ABs: -    sum += pair[0] -    if sum > pair[1]: +for A, B in ABs: +    sum += A +    if sum > B: