n,m = map(int,input().split())
down,up = 0,10**5
for _ in range(m):
  l,r = map(int,input().split())
  down = max(l,down)
  up = min(r,up)
print(max(up-down+1,0)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m down,up = 0,10**5 down 0 up 10**5 10 5 for _ in range(m):
  l,r = map(int,input().split())
  down = max(l,down)
  up = min(r,up) _ range(m) range m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r down = max(l,down) down max(l,down) max l down up = min(r,up) up min(r,up) min r up print(max(up-down+1,0)) print max(up-down+1,0) max up-down+1 up-down up down 1 0 up = 0,10**5 10**5 up l,r = map(int,input().split()) map(int,input().split()) l down,up = 0,10**5 0 down n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m down = max(l,down) max(l,down) down up = min(r,up) min(r,up) up r = map(int,input().split()) map(int,input().split()) r
n,m = map(int,input().split())
down,up = 0,10**5
for _ in range(m):
  l,r = map(int,input().split())
  down = max(l,down)
  up = min(r,up)
print(max(up-down+1,0))