import heapq



N = int(eval(input()))

tasks = []

for _ in range(N):

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

  if b-a < 0:

    print('No')

    exit()

  else:

    heapq.heappush(tasks,[b,-a])

    

day = 0

while len(tasks) != 0:

  b, neg_a = heapq.heappop(tasks)

  if day - neg_a > b:

    print('No')

    exit()

  else: day -= neg_a

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

deadlines = []

for i in range(N):

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

    deadlines.append([b, a])

deadlines.sort()



time = 0

for deadline, task_time in deadlines:

    if time + task_time <= deadline:

        time += task_time

    else:

        time = None

        break

print(('Yes' if time is not None else 'No'))
import heapq

N = int(eval(input()))
tasks = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    if b - a < 0:
        print("No")
        exit()
    else:
        heapq.heappush(tasks, [b, -a])
day = 0
while len(tasks) != 0:
    b, neg_a = heapq.heappop(tasks)
    if day - neg_a > b:
        print("No")
        exit()
    else:
        day -= neg_a
print("Yes")

N = int(eval(input()))
deadlines = []
for i in range(N):
    a, b = list(map(int, input().split()))
    deadlines.append([b, a])
deadlines.sort()
time = 0
for deadline, task_time in deadlines:
    if time + task_time <= deadline:
        time += task_time
    else:
        time = None
        break
print(("Yes" if time is not None else "No"))

-import heapq - -tasks = [] -for _ in range(N): +deadlines = [] +for i in range(N): -    if b - a < 0: -        print("No") -        exit() +    deadlines.append([b, a]) +deadlines.sort() +time = 0 +for deadline, task_time in deadlines: +    if time + task_time <= deadline: +        time += task_time -        heapq.heappush(tasks, [b, -a]) -day = 0 -while len(tasks) != 0: -    b, neg_a = heapq.heappop(tasks) -    if day - neg_a > b: -        print("No") -        exit() -    else: -        day -= neg_a -print("Yes") +        time = None +        break +print(("Yes" if time is not None else "No"))