N = int(eval(input()))

X = [list(map(int, input().split())) for _ in range(N)]



X.sort(key=lambda x: (x[1], x[0]))

cnt = 0

for a, b in X:

    if cnt + a <= b:

        cnt += a

    else:

        print('No')

        break

else:

    print('Yes')

N = int(eval(input()))

X = [list(map(int, input().split())) for _ in range(N)]



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

t = 0

ans = "No"

for a, b in X:

    if t + a > b:

        break

    t += a

else:

    ans = "Yes"

print(ans)



N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: (x[1], x[0]))
cnt = 0
for a, b in X:
    if cnt + a <= b:
        cnt += a
    else:
        print("No")
        break
else:
    print("Yes")

N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[1])
t = 0
ans = "No"
for a, b in X:
    if t + a > b:
        break
    t += a
else:
    ans = "Yes"
print(ans)

-X.sort(key=lambda x: (x[1], x[0])) -cnt = 0 +X.sort(key=lambda x: x[1]) +t = 0 +ans = "No" -    if cnt + a <= b: -        cnt += a -    else: -        print("No") +    if t + a > b: +    t += a -    print("Yes") +    ans = "Yes" +print(ans)