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