n, m = map(int, input().split())

left = 1
right = n+1

for i in range(m):
    l, r = map(int, input().split())
    left = max(left, l)
    right = min(right, r)

ans = right-left+1
print(ans if ans >= 0 else 0) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m left = 1 left 1 right = n+1 right n+1 n 1 for i in range(m):
    l, r = map(int, input().split())
    left = max(left, l)
    right = min(right, r) i range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r left = max(left, l) left max(left, l) max left l right = min(right, r) right min(right, r) min right r ans = right-left+1 ans right-left+1 right-left right left 1 print(ans if ans >= 0 else 0) print ans if ans >= 0 else 0 ans >= 0 ans 0 ans 0 left = 1 1 left right = min(right, r) min(right, r) right right = n+1 n+1 right ans = right-left+1 right-left+1 ans m = map(int, input().split()) map(int, input().split()) m left = max(left, l) max(left, l) left n, m = map(int, input().split()) map(int, input().split()) n l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r
n, m = map(int, input().split())

left = 1
right = n+1

for i in range(m):
    l, r = map(int, input().split())
    left = max(left, l)
    right = min(right, r)

ans = right-left+1
print(ans if ans >= 0 else 0)