N, M = list(map(lambda n: int(n), input().split(" ")))
L = []
R = []
for i in range(M):
  tmp = input().split(" ")
  L.append(int(tmp[0]))
  R.append(int(tmp[1]))

maxL = max(L)
minR = min(R)

print(max([minR - maxL + 1, 0])) N, M = list(map(lambda n: int(n), input().split(" "))) N list(map(lambda n: int(n), input().split(" "))) list map(lambda n: int(n), input().split(" ")) map lambda n: int(n) int(n) int n n input().split(" ") ().split () input split " " M L = [] L [] R = [] R [] for i in range(M):
  tmp = input().split(" ")
  L.append(int(tmp[0]))
  R.append(int(tmp[1])) i range(M) range M tmp = input().split(" ") tmp input().split(" ") ().split () input split " " L.append(int(tmp[0])) L.append L append int(tmp[0]) int tmp[0] tmp 0 R.append(int(tmp[1])) R.append R append int(tmp[1]) int tmp[1] tmp 1 maxL = max(L) maxL max(L) max L minR = min(R) minR min(R) min R print(max([minR - maxL + 1, 0])) print max([minR - maxL + 1, 0]) max [minR - maxL + 1, 0] minR - maxL + 1 minR - maxL minR maxL 1 0 R = [] [] R minR = min(R) min(R) minR L = [] [] L N, M = list(map(lambda n: int(n), input().split(" "))) list(map(lambda n: int(n), input().split(" "))) N tmp = input().split(" ") input().split(" ") tmp maxL = max(L) max(L) maxL M = list(map(lambda n: int(n), input().split(" "))) list(map(lambda n: int(n), input().split(" "))) M
N, M = list(map(lambda n: int(n), input().split(" ")))
L = []
R = []
for i in range(M):
  tmp = input().split(" ")
  L.append(int(tmp[0]))
  R.append(int(tmp[1]))

maxL = max(L)
minR = min(R)

print(max([minR - maxL + 1, 0]))