n, m = map(int, input().split())
lmax, rmin = map(int, input().split())
for i in range(1, m):
  l, r = map(int, input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)
print(max(0, rmin-lmax+1)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m lmax, rmin = map(int, input().split()) lmax map(int, input().split()) map int input().split() ().split () input split rmin for i in range(1, m):
  l, r = map(int, input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r) i range(1, m) range 1 m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r lmax = max(lmax, l) lmax max(lmax, l) max lmax l rmin = min(rmin, r) rmin min(rmin, r) min rmin r print(max(0, rmin-lmax+1)) print max(0, rmin-lmax+1) max 0 rmin-lmax+1 rmin-lmax rmin lmax 1 lmax = max(lmax, l) max(lmax, l) lmax lmax, rmin = map(int, input().split()) map(int, input().split()) lmax l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r rmin = map(int, input().split()) map(int, input().split()) rmin n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m rmin = min(rmin, r) min(rmin, r) rmin
n, m = map(int, input().split())
lmax, rmin = map(int, input().split())
for i in range(1, m):
  l, r = map(int, input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)
print(max(0, rmin-lmax+1))