N,M=map(int,input().split())
l=[]
r=[]
for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
a=max(l)
b=min(r)
x=list(range(a,b+1))
print(len(x)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M l=[] l [] r=[] r [] for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.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 l.append(L) l.append l append L r.append(R) r.append r append R a=max(l) a max(l) max l b=min(r) b min(r) min r x=list(range(a,b+1)) x list(range(a,b+1)) list range(a,b+1) range a b+1 b 1 print(len(x)) print len(x) len x L,R=map(int,input().split()) map(int,input().split()) L R=map(int,input().split()) map(int,input().split()) R x=list(range(a,b+1)) list(range(a,b+1)) x M=map(int,input().split()) map(int,input().split()) M r=[] [] r N,M=map(int,input().split()) map(int,input().split()) N b=min(r) min(r) b l=[] [] l a=max(l) max(l) a
N,M=map(int,input().split())
l=[]
r=[]
for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
a=max(l)
b=min(r)
x=list(range(a,b+1))
print(len(x))