N=int(eval(input()))

d=[]

for n in range(N):

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

d_1=sorted(d,key=lambda d:d[1])

t=0

for n in range(N):

    t+=d_1[n][0]

    if t>d_1[n][1]:

        print("No")

        exit(0)

print("Yes")
N=int(eval(input()))

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

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

t=0

for n in range(N):

    t+=lst_[n][0]

    if t>lst_[n][1]:

        print("No")

        exit(0)

print("Yes")
N = int(eval(input()))
d = []
for n in range(N):
    d.append(list(map(int, input().split())))
d_1 = sorted(d, key=lambda d: d[1])
t = 0
for n in range(N):
    t += d_1[n][0]
    if t > d_1[n][1]:
        print("No")
        exit(0)
print("Yes")

N = int(eval(input()))
lst = [tuple(map(int, input().split())) for _ in range(N)]
lst_ = sorted(lst, key=lambda x: x[1])
t = 0
for n in range(N):
    t += lst_[n][0]
    if t > lst_[n][1]:
        print("No")
        exit(0)
print("Yes")

-d = [] -for n in range(N): -    d.append(list(map(int, input().split()))) -d_1 = sorted(d, key=lambda d: d[1]) +lst = [tuple(map(int, input().split())) for _ in range(N)] +lst_ = sorted(lst, key=lambda x: x[1]) -    t += d_1[n][0] -    if t > d_1[n][1]: +    t += lst_[n][0] +    if t > lst_[n][1]: