N=int(eval(input()))

task=[]

for _ in range(N):

    task.append([int(i) for i in input().split()])



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



spent_time1=0

spent_time2=0

for i in range(N):

    spent_time2+=task[i][0]

ans='Yes'



for i in range(N):

    spent_time1+=task[i][0]

    deadline1=task[i][1]

    if i!=0:

        spent_time2-=task[N-i][0]

    deadline2=task[N-1-i][1]

    if deadline1<spent_time1:

        ans='No'

        break

    elif deadline2<spent_time2:

        ans='No'

        break

    



print(ans)
N=int(eval(input()))

task=[]

for _ in range(N):

    task.append([int(i) for i in input().split()])



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



spent_time1=0

ans='Yes'



for i in range(N):

    spent_time1+=task[i][0]

    deadline1=task[i][1]

    if deadline1<spent_time1:

        ans='No'

        break



print(ans)
N = int(eval(input()))
task = []
for _ in range(N):
    task.append([int(i) for i in input().split()])
task = sorted(task, key=lambda x: x[1])
spent_time1 = 0
spent_time2 = 0
for i in range(N):
    spent_time2 += task[i][0]
ans = "Yes"
for i in range(N):
    spent_time1 += task[i][0]
    deadline1 = task[i][1]
    if i != 0:
        spent_time2 -= task[N - i][0]
    deadline2 = task[N - 1 - i][1]
    if deadline1 < spent_time1:
        ans = "No"
        break
    elif deadline2 < spent_time2:
        ans = "No"
        break
print(ans)

N = int(eval(input()))
task = []
for _ in range(N):
    task.append([int(i) for i in input().split()])
task = sorted(task, key=lambda x: x[1])
spent_time1 = 0
ans = "Yes"
for i in range(N):
    spent_time1 += task[i][0]
    deadline1 = task[i][1]
    if deadline1 < spent_time1:
        ans = "No"
        break
print(ans)

-spent_time2 = 0 -for i in range(N): -    spent_time2 += task[i][0] -    if i != 0: -        spent_time2 -= task[N - i][0] -    deadline2 = task[N - 1 - i][1] -    elif deadline2 < spent_time2: -        ans = "No" -        break