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