N,M=map(int,input().split())

mm=0
mx=10**5
for _ in range(M):
    l,r = map(int,input().split())
    mm = max(mm,l)
    mx= min(mx,r)
print(max(mx-mm+1,0)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M mm=0 mm 0 mx=10**5 mx 10**5 10 5 for _ in range(M):
    l,r = map(int,input().split())
    mm = max(mm,l)
    mx= min(mx,r) _ range(M) range M l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r mm = max(mm,l) mm max(mm,l) max mm l mx= min(mx,r) mx min(mx,r) min mx r print(max(mx-mm+1,0)) print max(mx-mm+1,0) max mx-mm+1 mx-mm mx mm 1 0 mx=10**5 10**5 mx r = map(int,input().split()) map(int,input().split()) r N,M=map(int,input().split()) map(int,input().split()) N mm = max(mm,l) max(mm,l) mm M=map(int,input().split()) map(int,input().split()) M mm=0 0 mm mx= min(mx,r) min(mx,r) mx l,r = map(int,input().split()) map(int,input().split()) l
N,M=map(int,input().split())

mm=0
mx=10**5
for _ in range(M):
    l,r = map(int,input().split())
    mm = max(mm,l)
    mx= min(mx,r)
print(max(mx-mm+1,0))