n, m = map(int, input().split())
max_l = 0
min_r = 10 ** 10
for _ in range(m):
  l, r = map(int, input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(max(0, min_r - max_l + 1)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m max_l = 0 max_l 0 min_r = 10 ** 10 min_r 10 ** 10 10 10 for _ in range(m):
  l, r = map(int, input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r) _ range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r max_l = max(max_l, l) max_l max(max_l, l) max max_l l min_r = min(min_r, r) min_r min(min_r, r) min min_r r print(max(0, min_r - max_l + 1)) print max(0, min_r - max_l + 1) max 0 min_r - max_l + 1 min_r - max_l min_r max_l 1 min_r = 10 ** 10 10 ** 10 min_r n, m = map(int, input().split()) map(int, input().split()) n max_l = max(max_l, l) max(max_l, l) max_l r = map(int, input().split()) map(int, input().split()) r m = map(int, input().split()) map(int, input().split()) m max_l = 0 0 max_l l, r = map(int, input().split()) map(int, input().split()) l min_r = min(min_r, r) min(min_r, r) min_r
n, m = map(int, input().split())
max_l = 0
min_r = 10 ** 10
for _ in range(m):
  l, r = map(int, input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(max(0, min_r - max_l + 1))