N = int(eval(input()))

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



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



import sys

work = 0



for i in range(N):

    work += sortedAB[i][0]

    if work > sortedAB[i][1]:

        print('No')

        sys.exit()

        

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

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



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

ans = 'Yes'

tmp = 0



for i in range(N):

    tmp += sort_AB[i][0]

    if tmp > sort_AB[i][1]:

        ans = 'No'

        break

        

print(ans)
N = int(eval(input()))
AB = [list(map(int, input().split())) for i in range(N)]
sortedAB = sorted(AB, key=lambda x: x[1])
import sys

work = 0
for i in range(N):
    work += sortedAB[i][0]
    if work > sortedAB[i][1]:
        print("No")
        sys.exit()
print("Yes")

N = int(eval(input()))
AB = [list(map(int, input().split())) for i in range(N)]
sort_AB = sorted(AB, key=lambda x: x[1])
ans = "Yes"
tmp = 0
for i in range(N):
    tmp += sort_AB[i][0]
    if tmp > sort_AB[i][1]:
        ans = "No"
        break
print(ans)

-sortedAB = sorted(AB, key=lambda x: x[1]) -import sys - -work = 0 +sort_AB = sorted(AB, key=lambda x: x[1]) +ans = "Yes" +tmp = 0 -    work += sortedAB[i][0] -    if work > sortedAB[i][1]: -        print("No") -        sys.exit() -print("Yes") +    tmp += sort_AB[i][0] +    if tmp > sort_AB[i][1]: +        ans = "No" +        break +print(ans)