n = int(eval(input()))



num_list = []



for _ in range(n):

    nums = list(map(int, input().split()))

    num_list.append(nums)



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



count = 0



for i in range(n):

    count += num_list[i][0]

    if count > num_list[i][1]:

        print('No')

        exit()



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



jobs = []



for i in range(n):

    array = list(map(int, input().split()))

    jobs.append(array)



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



time = 0



for i, j in jobs:

    time += i

    if time <= j:

        continue

    else:

        print('No')

        exit()

print('Yes')
n = int(eval(input()))
num_list = []
for _ in range(n):
    nums = list(map(int, input().split()))
    num_list.append(nums)
num_list = sorted(num_list, key=lambda x: x[1])
count = 0
for i in range(n):
    count += num_list[i][0]
    if count > num_list[i][1]:
        print("No")
        exit()
print("Yes")

n = int(eval(input()))
jobs = []
for i in range(n):
    array = list(map(int, input().split()))
    jobs.append(array)
jobs.sort(key=lambda x: x[1])
time = 0
for i, j in jobs:
    time += i
    if time <= j:
        continue
    else:
        print("No")
        exit()
print("Yes")

-num_list = [] -for _ in range(n): -    nums = list(map(int, input().split())) -    num_list.append(nums) -num_list = sorted(num_list, key=lambda x: x[1]) -count = 0 +jobs = [] -    count += num_list[i][0] -    if count > num_list[i][1]: +    array = list(map(int, input().split())) +    jobs.append(array) +jobs.sort(key=lambda x: x[1]) +time = 0 +for i, j in jobs: +    time += i +    if time <= j: +        continue +    else: