N, M = map(int, input().split())

L, R = 0, 10 ** 5 + 1
for _ in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r+1)

if R > L:
    result = R - L
else:
    result = 0
print(result) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L, R = 0, 10 ** 5 + 1 L 0 R 10 ** 5 + 1 10 ** 5 10 5 1 for _ in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r+1) _ range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r L = max(L, l) L max(L, l) max L l R = min(R, r+1) R min(R, r+1) min R r+1 r 1 if R > L:
    result = R - L
else:
    result = 0 R > L R L result = R - L result R - L R L result = 0 result 0 print(result) print result l, r = map(int, input().split()) map(int, input().split()) l M = map(int, input().split()) map(int, input().split()) M R = 0, 10 ** 5 + 1 10 ** 5 + 1 R r = map(int, input().split()) map(int, input().split()) r R = min(R, r+1) min(R, r+1) R L = max(L, l) max(L, l) L result = 0 0 result N, M = map(int, input().split()) map(int, input().split()) N L, R = 0, 10 ** 5 + 1 0 L result = R - L R - L result
N, M = map(int, input().split())

L, R = 0, 10 ** 5 + 1
for _ in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r+1)

if R > L:
    result = R - L
else:
    result = 0
print(result)