from operator import itemgetter

n=int(eval(input()))

ab=[list(map(int,input().split())) for i in range(n)]

ab=sorted(ab, key=itemgetter(1,0))

#print(ab)



time=0

for todotime,deadline in ab:

    time += todotime

    if not (time <= deadline) :

        print('No')

        exit()

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

ab=[list(map(int,input().split())) for i in range(n)]

ab.sort(key=lambda x:x[1])

#print(ab)

time=0

for a,b in ab:

    temp=time+a

    if temp<=b:

        time=temp

    else:

        print('No')

        exit()

print('Yes')
from operator import itemgetter

n = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(n)]
ab = sorted(ab, key=itemgetter(1, 0))
# print(ab)
time = 0
for todotime, deadline in ab:
    time += todotime
    if not (time <= deadline):
        print("No")
        exit()
print("Yes")

n = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
# print(ab)
time = 0
for a, b in ab:
    temp = time + a
    if temp <= b:
        time = temp
    else:
        print("No")
        exit()
print("Yes")

-from operator import itemgetter - -ab = sorted(ab, key=itemgetter(1, 0)) +ab.sort(key=lambda x: x[1]) -for todotime, deadline in ab: -    time += todotime -    if not (time <= deadline): +for a, b in ab: +    temp = time + a +    if temp <= b: +        time = temp +    else: