n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

INF = float('inf')
ans_l, ans_r = -INF, INF
for l, r in lr:
    ans_l = max(ans_l, l)
    ans_r = min(ans_r, r)
print(max(0, ans_r-ans_l+1)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split lr = [list(map(int, input().split())) for _ in range(m)] lr [list(map(int, input().split())) for _ in range(m)] INF = float('inf') INF float('inf') float 'inf' ans_l, ans_r = -INF, INF ans_l -INF INF ans_r INF for l, r in lr:
    ans_l = max(ans_l, l)
    ans_r = min(ans_r, r) l r lr ans_l = max(ans_l, l) ans_l max(ans_l, l) max ans_l l ans_r = min(ans_r, r) ans_r min(ans_r, r) min ans_r r print(max(0, ans_r-ans_l+1)) print max(0, ans_r-ans_l+1) max 0 ans_r-ans_l+1 ans_r-ans_l ans_r ans_l 1 m = map(int, input().split()) map(int, input().split()) m ans_r = min(ans_r, r) min(ans_r, r) ans_r ans_r = -INF, INF INF ans_r ans_l, ans_r = -INF, INF -INF ans_l lr = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] lr ans_l = max(ans_l, l) max(ans_l, l) ans_l n, m = map(int, input().split()) map(int, input().split()) n INF = float('inf') float('inf') INF
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

INF = float('inf')
ans_l, ans_r = -INF, INF
for l, r in lr:
    ans_l = max(ans_l, l)
    ans_r = min(ans_r, r)
print(max(0, ans_r-ans_l+1))