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'))

n = int(eval(input()))

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

# time/limit



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



flg = True

cur = 0

for t, lm in tlm:

    cur += t

    if cur > lm:

        flg = False

        break



print(('Yes' if flg 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"))

n = int(eval(input()))
tlm = [tuple(map(int, input().split())) for _ in range(n)]
# time/limit
tlm.sort(key=lambda x: x[1])
flg = True
cur = 0
for t, lm in tlm:
    cur += t
    if cur > lm:
        flg = False
        break
print(("Yes" if flg else "No"))

-e = [] -for _ in range(n): -    a, b = list(map(int, input().split())) -    e.append((b, a)) -e.sort() +tlm = [tuple(map(int, input().split())) for _ in range(n)] +# time/limit +tlm.sort(key=lambda x: x[1]) +flg = True -can = True -for b, a in e: -    cur += a -    if cur > b: -        can = False +for t, lm in tlm: +    cur += t +    if cur > lm: +        flg = False -print(("Yes" if can else "No")) +print(("Yes" if flg else "No"))