N = int(eval(input()))

d = {}

total = 0

for _ in range(N):

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

    d[b] = d.get(b, 0) + a

for t, c in sorted(d.items()):

    total += c

    if total > t:

        print("No")

        exit()

print("Yes")

n = int(eval(input()))

w = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])

agg = 0

for c, t in w:

    agg += c

    if t < agg:

        print("No")

        exit()

print("Yes")



N = int(eval(input()))
d = {}
total = 0
for _ in range(N):
    a, b = list(map(int, input().split()))
    d[b] = d.get(b, 0) + a
for t, c in sorted(d.items()):
    total += c
    if total > t:
        print("No")
        exit()
print("Yes")

n = int(eval(input()))
w = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])
agg = 0
for c, t in w:
    agg += c
    if t < agg:
        print("No")
        exit()
print("Yes")

-N = int(eval(input())) -d = {} -total = 0 -for _ in range(N): -    a, b = list(map(int, input().split())) -    d[b] = d.get(b, 0) + a -for t, c in sorted(d.items()): -    total += c -    if total > t: +n = int(eval(input())) +w = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1]) +agg = 0 +for c, t in w: +    agg += c +    if t < agg: