N, M = map(int, input().split())
id = [0 for i in range(N)]

max_l = 0
min_r = 100000
for _ in range(M):
  l, r = map(int, input().split())
  if max_l < l:
    max_l = l
  if min_r > r:
    min_r = r

id = min_r-max_l+1
print(0 if id <0 else id) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M 0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 0 id = [0 for i in range(N)] id [0 for i in range(N)] max_l = 0 max_l 0 min_r = 100000 min_r 100000 for _ in range(M):
  l, r = map(int, input().split())
  if max_l < l:
    max_l = l
  if min_r > r:
    min_r = 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 max_l < l:
    max_l = l
   max_l < l max_l l max_l = l max_l l if min_r > r:
    min_r = r min_r > r min_r r min_r = r min_r r id = min_r-max_l+1 id min_r-max_l+1 min_r-max_l min_r max_l 1 print(0 if id <0 else id) print 0 if id <0 else id id <0 id 0 0 id max_l = 0 0 max_l M = map(int, input().split()) map(int, input().split()) M l, r = map(int, input().split()) map(int, input().split()) l N, M = map(int, input().split()) map(int, input().split()) N id = min_r-max_l+1 min_r-max_l+1 id min_r = r r min_r min_r = 100000 100000 min_r id = [0 for i in range(N)] [0 for i in range(N)] id r = map(int, input().split()) map(int, input().split()) r max_l = l l max_l
N, M = map(int, input().split())
id = [0 for i in range(N)]

max_l = 0
min_r = 100000
for _ in range(M):
  l, r = map(int, input().split())
  if max_l < l:
    max_l = l
  if min_r > r:
    min_r = r

id = min_r-max_l+1
print(0 if id <0 else id)