n, m = map(int, input().split())
l, r = [0] * m, [0] * m
for i in range(m):
    li, ri = map(int, input().split())
    l[i] = li
    r[i] = ri
maxl = max(l)
minr = min(r)
if minr < maxl:
    print(0)
else:
    print(minr - maxl + 1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l, r = [0] * m, [0] * m l [0] * m [0] 0 m r [0] * m [0] 0 m for i in range(m):
    li, ri = map(int, input().split())
    l[i] = li
    r[i] = ri i range(m) range m li, ri = map(int, input().split()) li map(int, input().split()) map int input().split() ().split () input split ri l[i] = li l[i] l i li r[i] = ri r[i] r i ri maxl = max(l) maxl max(l) max l minr = min(r) minr min(r) min r if minr < maxl:
    print(0)
else:
    print(minr - maxl + 1) minr < maxl minr maxl print(0) print 0 print(minr - maxl + 1) print minr - maxl + 1 minr - maxl minr maxl 1 n, m = map(int, input().split()) map(int, input().split()) n r = [0] * m, [0] * m [0] * m r l, r = [0] * m, [0] * m [0] * m l li, ri = map(int, input().split()) map(int, input().split()) li maxl = max(l) max(l) maxl m = map(int, input().split()) map(int, input().split()) m minr = min(r) min(r) minr ri = map(int, input().split()) map(int, input().split()) ri
n, m = map(int, input().split())
l, r = [0] * m, [0] * m
for i in range(m):
    li, ri = map(int, input().split())
    l[i] = li
    r[i] = ri
maxl = max(l)
minr = min(r)
if minr < maxl:
    print(0)
else:
    print(minr - maxl + 1)
