n,m = map(int,input().split())


l = [1]*n
L,R = 0,float('inf')
for _ in range(m):
    a,b = map(int,input().split())
    L = max(L,a)
    R = min(R,b)
ans = R-L+1
if ans<=0:ans = 0
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l = [1]*n l [1]*n [1] 1 n L,R = 0,float('inf') L 0 R float('inf') float 'inf' for _ in range(m):
    a,b = map(int,input().split())
    L = max(L,a)
    R = min(R,b) _ range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b L = max(L,a) L max(L,a) max L a R = min(R,b) R min(R,b) min R b ans = R-L+1 ans R-L+1 R-L R L 1 if ans<=0:ans = 0 ans<=0 ans 0 print(ans) print ans L,R = 0,float('inf') 0 L b = map(int,input().split()) map(int,input().split()) b l = [1]*n [1]*n l ans = R-L+1 R-L+1 ans R = 0,float('inf') float('inf') R m = map(int,input().split()) map(int,input().split()) m a,b = map(int,input().split()) map(int,input().split()) a R = min(R,b) min(R,b) R n,m = map(int,input().split()) map(int,input().split()) n L = max(L,a) max(L,a) L
n,m = map(int,input().split())


l = [1]*n
L,R = 0,float('inf')
for _ in range(m):
    a,b = map(int,input().split())
    L = max(L,a)
    R = min(R,b)
ans = R-L+1
if ans<=0:ans = 0
print(ans)
