n = int(eval(input()))

w = []

for i in range(n):

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

    w.append([a,b])

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

time = 0

for i in range(n):

    time += w[i][0]

    if time > w[i][1]:

        print("No")

        exit()

print("Yes")

n = int(eval(input()))

task = []

for i in range(n):

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

    task.append((a,b))

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

time = 0

deadline = 0

for i in range(n):

    time += task[i][0]

    deadline = task[i][1]

    if time > deadline:

        print("No")

        exit()

print("Yes")

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

n = int(eval(input()))
task = []
for i in range(n):
    a, b = list(map(int, input().split()))
    task.append((a, b))
task.sort(key=lambda x: x[1])
time = 0
deadline = 0
for i in range(n):
    time += task[i][0]
    deadline = task[i][1]
    if time > deadline:
        print("No")
        exit()
print("Yes")

-w = [] +task = [] -    w.append([a, b]) -w.sort(key=lambda x: x[1]) +    task.append((a, b)) +task.sort(key=lambda x: x[1]) +deadline = 0 -    time += w[i][0] -    if time > w[i][1]: +    time += task[i][0] +    deadline = task[i][1] +    if time > deadline: