N,M=map(int,input().split())
left=1
right=N
for i in range(M):
  L,R=map(int,input().split())
  left=max(left,L)
  right=min(right,R)
print(max(0,right-left+1)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M left=1 left 1 right=N right N for i in range(M):
  L,R=map(int,input().split())
  left=max(left,L)
  right=min(right,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 left=max(left,L) left max(left,L) max left L right=min(right,R) right min(right,R) min right R print(max(0,right-left+1)) print max(0,right-left+1) max 0 right-left+1 right-left right left 1 N,M=map(int,input().split()) map(int,input().split()) N L,R=map(int,input().split()) map(int,input().split()) L M=map(int,input().split()) map(int,input().split()) M right=min(right,R) min(right,R) right left=1 1 left right=N N right R=map(int,input().split()) map(int,input().split()) R left=max(left,L) max(left,L) left
N,M=map(int,input().split())
left=1
right=N
for i in range(M):
  L,R=map(int,input().split())
  left=max(left,L)
  right=min(right,R)
print(max(0,right-left+1))