from operator import itemgetter



N = int(eval(input()))



wl = [tuple(map(int, input().split())) for _ in range(N)]

wl.sort(key=itemgetter(1))

# (work_time, time_limit)



cur = 0

can = True

for t, lmt in wl:

    cur += t

    if cur > lmt:

        can = False

        break

print(('Yes' if can else 'No'))

n = int(eval(input()))

e = []

for _ in range(n):

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

    e.append((b, a))

e.sort()



cur = 0

can = True

for b, a in e:

    cur += a

    if cur > b:

        can = False

        break



print(('Yes' if can else 'No'))

from operator import itemgetter

N = int(eval(input()))
wl = [tuple(map(int, input().split())) for _ in range(N)]
wl.sort(key=itemgetter(1))
# (work_time, time_limit)
cur = 0
can = True
for t, lmt in wl:
    cur += t
    if cur > lmt:
        can = False
        break
print(("Yes" if can else "No"))

n = int(eval(input()))
e = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    e.append((b, a))
e.sort()
cur = 0
can = True
for b, a in e:
    cur += a
    if cur > b:
        can = False
        break
print(("Yes" if can else "No"))

-from operator import itemgetter - -N = int(eval(input())) -wl = [tuple(map(int, input().split())) for _ in range(N)] -wl.sort(key=itemgetter(1)) -# (work_time, time_limit) +n = int(eval(input())) +e = [] +for _ in range(n): +    a, b = list(map(int, input().split())) +    e.append((b, a)) +e.sort() -for t, lmt in wl: -    cur += t -    if cur > lmt: +for b, a in e: +    cur += a +    if cur > b: