N=int(eval(input()))

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

s=0

p=True

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

for l in L:

    s+=l[0]

    if l[1]>=s:

        continue

    else:

        p=False

        break

print(("Yes" if p else "No"))

N=int(eval(input()))

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

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

t=0

p=True

for l in L:

  t+=l[0]

  if t > l[1]:

    p=False

    break

print(("Yes" if p else "No"))
N = int(eval(input()))
L = [list(map(int, input().split())) for _ in range(N)]
s = 0
p = True
L = sorted(L, key=lambda x: x[1])
for l in L:
    s += l[0]
    if l[1] >= s:
        continue
    else:
        p = False
        break
print(("Yes" if p else "No"))

N = int(eval(input()))
L = [list(map(int, input().split())) for _ in range(N)]
L.sort(key=lambda x: x[1])
t = 0
p = True
for l in L:
    t += l[0]
    if t > l[1]:
        p = False
        break
print(("Yes" if p else "No"))

-s = 0 +L.sort(key=lambda x: x[1]) +t = 0 -L = sorted(L, key=lambda x: x[1]) -    s += l[0] -    if l[1] >= s: -        continue -    else: +    t += l[0] +    if t > l[1]: