n, m = map(int, input().split())
l, r = [0] * m, [0] * m
for i in range(m):
    l[i], r[i] = map(int, input().split())
print(max(min(r) - max(l) + 1, 0)) 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):
    l[i], r[i] = map(int, input().split()) i range(m) range m l[i], r[i] = map(int, input().split()) l[i] l i map(int, input().split()) map int input().split() ().split () input split r[i] r i print(max(min(r) - max(l) + 1, 0)) print max(min(r) - max(l) + 1, 0) max min(r) - max(l) + 1 min(r) - max(l) min(r) min r max(l) max l 1 0 m = map(int, input().split()) map(int, input().split()) m r = [0] * m, [0] * m [0] * m r l, r = [0] * m, [0] * m [0] * m l n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
l, r = [0] * m, [0] * m
for i in range(m):
    l[i], r[i] = map(int, input().split())
print(max(min(r) - max(l) + 1, 0))