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())
ans = max(min(R)-max(L)+1, 0)
print(ans) 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 ans = max(min(R)-max(L)+1, 0) ans max(min(R)-max(L)+1, 0) max min(R)-max(L)+1 min(R)-max(L) min(R) min R max(L) max L 1 0 print(ans) print ans L = [0]*m [0]*m L R = [0]*m [0]*m R ans = max(min(R)-max(L)+1, 0) max(min(R)-max(L)+1, 0) ans m = map(int,input().split()) map(int,input().split()) m n, m = map(int,input().split()) map(int,input().split()) n
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())
ans = max(min(R)-max(L)+1, 0)
print(ans)