N,M = map(int,input().split())
a = list()
b = list()
for i in range(M):
  tmp_a,tmp_b =  map(int, input().split())
  a.append(tmp_a)
  b.append(tmp_b)
print(min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M a = list() a list() list b = list() b list() list for i in range(M):
  tmp_a,tmp_b =  map(int, input().split())
  a.append(tmp_a)
  b.append(tmp_b) i range(M) range M tmp_a,tmp_b =  map(int, input().split()) tmp_a map(int, input().split()) map int input().split() ().split () input split tmp_b a.append(tmp_a) a.append a append tmp_a b.append(tmp_b) b.append b append tmp_b print(min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0) print min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0 min(b)-max(a) >= 0 min(b)-max(a) min(b) min b max(a) max a 0 min(b)-max(a)+1 min(b)-max(a) min(b) min b max(a) max a 1 0 N,M = map(int,input().split()) map(int,input().split()) N tmp_b =  map(int, input().split()) map(int, input().split()) tmp_b b = list() list() b M = map(int,input().split()) map(int,input().split()) M tmp_a,tmp_b =  map(int, input().split()) map(int, input().split()) tmp_a a = list() list() a
N,M = map(int,input().split())
a = list()
b = list()
for i in range(M):
  tmp_a,tmp_b =  map(int, input().split())
  a.append(tmp_a)
  b.append(tmp_b)
print(min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0)