N, *LR = list(map(int, open(0).read().split()))

L, R = LR[::2], LR[1::2]



max_l = max(L)

min_r = min(R)



ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]

ab.sort()



mi = float("inf")

ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)



for i in range(N - 1):

    mi = min(mi, -ab[i][1])

    ma = max(ma, mi + ab[i + 1][0])



print(ma)

N, *LR = list(map(int, open(0).read().split()))

L, R = LR[::2], LR[1::2]



max_l = max(L)

min_r = min(R)



A = sorted(max(0, r - max_l + 1) for r in R)

B = sorted(-max(0, min_r - l + 1) for l in L)



mi = float("inf")

ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)



for i in range(N - 1):

    mi = min(mi, -B[i])

    ma = max(ma, mi + A[i + 1])



print(ma)
N, *LR = list(map(int, open(0).read().split()))
L, R = LR[::2], LR[1::2]
max_l = max(L)
min_r = min(R)
ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]
ab.sort()
mi = float("inf")
ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
for i in range(N - 1):
    mi = min(mi, -ab[i][1])
    ma = max(ma, mi + ab[i + 1][0])
print(ma)

N, *LR = list(map(int, open(0).read().split()))
L, R = LR[::2], LR[1::2]
max_l = max(L)
min_r = min(R)
A = sorted(max(0, r - max_l + 1) for r in R)
B = sorted(-max(0, min_r - l + 1) for l in L)
mi = float("inf")
ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
for i in range(N - 1):
    mi = min(mi, -B[i])
    ma = max(ma, mi + A[i + 1])
print(ma)

-ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)] -ab.sort() +A = sorted(max(0, r - max_l + 1) for r in R) +B = sorted(-max(0, min_r - l + 1) for l in L) -    mi = min(mi, -ab[i][1]) -    ma = max(ma, mi + ab[i + 1][0]) +    mi = min(mi, -B[i]) +    ma = max(ma, mi + A[i + 1])