

n = int(eval(input()))



data = []

for i in range(n):

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

    data.append([a, b])



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

flag = True

sum = 0

for i in range(n):

    sum += data[i][0]

    if sum > data[i][1]:

        flag = False

        break

print(("Yes" if flag == True else "No"))
n = int(eval(input()))

data = []



for i in range(n):

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

    data.append([a, b])

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

time = 0

ans = "Yes"

for i in range(n):

    if time + data[i][0] > data[i][1]:

        ans = "No"

    time += data[i][0]

print(ans)
n = int(eval(input()))
data = []
for i in range(n):
    a, b = list(map(int, input().split()))
    data.append([a, b])
data.sort(key=lambda x: x[1])
flag = True
sum = 0
for i in range(n):
    sum += data[i][0]
    if sum > data[i][1]:
        flag = False
        break
print(("Yes" if flag == True else "No"))

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

-data.sort(key=lambda x: x[1]) -flag = True -sum = 0 +data = sorted(data, key=lambda x: x[1]) +time = 0 +ans = "Yes" -    sum += data[i][0] -    if sum > data[i][1]: -        flag = False -        break -print(("Yes" if flag == True else "No")) +    if time + data[i][0] > data[i][1]: +        ans = "No" +    time += data[i][0] +print(ans)