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