N,M = map(int, input().split())
L = [0]*M
R = [0]*M

for i in range(M):
    L[i],R[i] = map(int, input().split())
    
l = max(L)
r = min(R)

print(max(r-l+1,0)) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [0]*M L [0]*M [0] 0 M R = [0]*M R [0]*M [0] 0 M for i in range(M):
    L[i],R[i] = map(int, input().split())
     i range(M) range M L[i],R[i] = map(int, input().split()) L[i] L i map(int, input().split()) map int input().split() ().split () input split R[i] R i l = max(L) l max(L) max L r = min(R) r min(R) min R print(max(r-l+1,0)) print max(r-l+1,0) max r-l+1 r-l r l 1 0 M = map(int, input().split()) map(int, input().split()) M R = [0]*M [0]*M R N,M = map(int, input().split()) map(int, input().split()) N l = max(L) max(L) l r = min(R) min(R) r L = [0]*M [0]*M L
N,M = map(int, input().split())
L = [0]*M
R = [0]*M

for i in range(M):
    L[i],R[i] = map(int, input().split())
    
l = max(L)
r = min(R)

print(max(r-l+1,0))