n, m = map(int, input().split())
l, r = [], []

for _ in range(m):
    s, t = map(int, input().split())
    l.append(int(s))
    r.append(int(t))

ans = min(r) - max(l) + 1 if min(r) >= max(l) else 0
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l, r = [], [] l [] r [] for _ in range(m):
    s, t = map(int, input().split())
    l.append(int(s))
    r.append(int(t)) _ range(m) range m s, t = map(int, input().split()) s map(int, input().split()) map int input().split() ().split () input split t l.append(int(s)) l.append l append int(s) int s r.append(int(t)) r.append r append int(t) int t ans = min(r) - max(l) + 1 if min(r) >= max(l) else 0 ans min(r) - max(l) + 1 if min(r) >= max(l) else 0 min(r) >= max(l) min(r) min r max(l) max l min(r) - max(l) + 1 min(r) - max(l) min(r) min r max(l) max l 1 0 print(ans) print ans n, m = map(int, input().split()) map(int, input().split()) n r = [], [] [] r s, t = map(int, input().split()) map(int, input().split()) s t = map(int, input().split()) map(int, input().split()) t m = map(int, input().split()) map(int, input().split()) m l, r = [], [] [] l ans = min(r) - max(l) + 1 if min(r) >= max(l) else 0 min(r) - max(l) + 1 if min(r) >= max(l) else 0 ans
n, m = map(int, input().split())
l, r = [], []

for _ in range(m):
    s, t = map(int, input().split())
    l.append(int(s))
    r.append(int(t))

ans = min(r) - max(l) + 1 if min(r) >= max(l) else 0
print(ans)
