n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    L, R = map(int, input().split())
    l += [L]
    r += [R]

l_max = max(l)
r_min = min(r)

print(max(r_min - l_max + 1, 0)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = [] l [] r = [] r [] for i in range(m):
    L, R = map(int, input().split())
    l += [L]
    r += [R] i range(m) range m L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R l += [L] l [L] L r += [R] r [R] R l_max = max(l) l_max max(l) max l r_min = min(r) r_min min(r) min r print(max(r_min - l_max + 1, 0)) print max(r_min - l_max + 1, 0) max r_min - l_max + 1 r_min - l_max r_min l_max 1 0 l = [] [] l r += [R] [R] r r_min = min(r) min(r) r_min r = [] [] r n, m = map(int, input().split()) map(int, input().split()) n R = map(int, input().split()) map(int, input().split()) R m = map(int, input().split()) map(int, input().split()) m l += [L] [L] l L, R = map(int, input().split()) map(int, input().split()) L l_max = max(l) max(l) l_max
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    L, R = map(int, input().split())
    l += [L]
    r += [R]

l_max = max(l)
r_min = min(r)

print(max(r_min - l_max + 1, 0))