n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]

max_l, min_r = 0, float("inf")
for i in range(m):
  max_l = max(s[i][0], max_l)
  min_r = min(s[i][1], min_r)
  
print(max(min_r - max_l + 1, 0)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = [list(map(int, input().split())) for _ in range(m)] s [list(map(int, input().split())) for _ in range(m)] max_l, min_r = 0, float("inf") max_l 0 min_r float("inf") float "inf" for i in range(m):
  max_l = max(s[i][0], max_l)
  min_r = min(s[i][1], min_r)
   i range(m) range m max_l = max(s[i][0], max_l) max_l max(s[i][0], max_l) max s[i][0] [i] s i 0 max_l min_r = min(s[i][1], min_r) min_r min(s[i][1], min_r) min s[i][1] [i] s i 1 min_r print(max(min_r - max_l + 1, 0)) print max(min_r - max_l + 1, 0) max min_r - max_l + 1 min_r - max_l min_r max_l 1 0 min_r = 0, float("inf") float("inf") min_r s = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] s m = map(int, input().split()) map(int, input().split()) m max_l, min_r = 0, float("inf") 0 max_l n, m = map(int, input().split()) map(int, input().split()) n max_l = max(s[i][0], max_l) max(s[i][0], max_l) max_l min_r = min(s[i][1], min_r) min(s[i][1], min_r) min_r
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]

max_l, min_r = 0, float("inf")
for i in range(m):
  max_l = max(s[i][0], max_l)
  min_r = min(s[i][1], min_r)
  
print(max(min_r - max_l + 1, 0))