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