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

st = 0
en = N

for _ in range(M):
    l, r = map(int, input().split())
    st = max(st, l)
    en = min(en, r)

print(max(en - st + 1, 0)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M st = 0 st 0 en = N en N for _ in range(M):
    l, r = map(int, input().split())
    st = max(st, l)
    en = min(en, r) _ range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r st = max(st, l) st max(st, l) max st l en = min(en, r) en min(en, r) min en r print(max(en - st + 1, 0)) print max(en - st + 1, 0) max en - st + 1 en - st en st 1 0 en = min(en, r) min(en, r) en st = max(st, l) max(st, l) st r = map(int, input().split()) map(int, input().split()) r N, M = map(int, input().split()) map(int, input().split()) N en = N N en M = map(int, input().split()) map(int, input().split()) M st = 0 0 st l, r = map(int, input().split()) map(int, input().split()) l
N, M = map(int, input().split())

st = 0
en = N

for _ in range(M):
    l, r = map(int, input().split())
    st = max(st, l)
    en = min(en, r)

print(max(en - st + 1, 0))