N, M = map(int, input().split())
res = 0
L_max = 0
R_min = 100000
for _ in range(M):
  L, R = map(int, input().split())
  if L_max < L: L_max = L
  if R < R_min: R_min = R
  
  
print(max(0, (R_min - L_max + 1))) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M res = 0 res 0 L_max = 0 L_max 0 R_min = 100000 R_min 100000 for _ in range(M):
  L, R = map(int, input().split())
  if L_max < L: L_max = L
  if R < R_min: R_min = R
  
   _ range(M) range M L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R if L_max < L: L_max = L
   L_max < L L_max L if R < R_min: R_min = R
  
   R < R_min R R_min print(max(0, (R_min - L_max + 1))) print max(0, (R_min - L_max + 1)) max 0 R_min - L_max + 1 R_min - L_max R_min L_max 1 res = 0 0 res L, R = map(int, input().split()) map(int, input().split()) L N, M = map(int, input().split()) map(int, input().split()) N R = map(int, input().split()) map(int, input().split()) R L_max = 0 0 L_max M = map(int, input().split()) map(int, input().split()) M R_min = 100000 100000 R_min
N, M = map(int, input().split())
res = 0
L_max = 0
R_min = 100000
for _ in range(M):
  L, R = map(int, input().split())
  if L_max < L: L_max = L
  if R < R_min: R_min = R
  
  
print(max(0, (R_min - L_max + 1)))