n = int(eval(input()))

a = []

for i in range(n):

    a.append(list(map(int, input().split())))



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



cnt = 0

for i in range(n):

    cnt += a[i][0]

    # print(cnt, a[i][1])

    if cnt > a[i][1]:

        print('No')

        exit()



print('Yes')

n = int(eval(input()))



a = []

for i in range(n):

    A, B = list(map(int, input().split()))

    a.append([A, B])



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

# print(b)



t = 0

for i in range(n):

    t += b[i][0]

    if t > b[i][1]:

        print('No')

        exit()

print('Yes')

n = int(eval(input()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x: x[1])
cnt = 0
for i in range(n):
    cnt += a[i][0]
    # print(cnt, a[i][1])
    if cnt > a[i][1]:
        print("No")
        exit()
print("Yes")

n = int(eval(input()))
a = []
for i in range(n):
    A, B = list(map(int, input().split()))
    a.append([A, B])
b = sorted(a, key=lambda x: x[1])
# print(b)
t = 0
for i in range(n):
    t += b[i][0]
    if t > b[i][1]:
        print("No")
        exit()
print("Yes")

-    a.append(list(map(int, input().split()))) -a.sort(key=lambda x: x[1]) -cnt = 0 +    A, B = list(map(int, input().split())) +    a.append([A, B]) +b = sorted(a, key=lambda x: x[1]) +# print(b) +t = 0 -    cnt += a[i][0] -    # print(cnt, a[i][1]) -    if cnt > a[i][1]: +    t += b[i][0] +    if t > b[i][1]: