N = int(eval(input()))



lst = []

for i in range(N):

  N, K = list(map(int, input().split()))

  lst.append((K-N, N, K))



lst.sort()

lst.sort(key=lambda tup: tup[2])

count = 0

for ind, x in enumerate(lst):

  if count > x[0]:

    print("No")

    exit()

  count += x[1]



print("Yes")

N = int(eval(input()))



lst = []

for i in range(N):

  N, K = list(map(int, input().split()))

  lst.append((K-N, N, K))



lst.sort(key=lambda tup: tup[2])

count = 0

for ind, x in enumerate(lst):

  if count > x[0]:

    print("No")

    exit()

  count += x[1]



print("Yes")

N = int(eval(input()))
lst = []
for i in range(N):
    N, K = list(map(int, input().split()))
    lst.append((K - N, N, K))
lst.sort()
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
    if count > x[0]:
        print("No")
        exit()
    count += x[1]
print("Yes")

N = int(eval(input()))
lst = []
for i in range(N):
    N, K = list(map(int, input().split()))
    lst.append((K - N, N, K))
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
    if count > x[0]:
        print("No")
        exit()
    count += x[1]
print("Yes")

-lst.sort()