N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)

L_max = 0
R_min = 100000

for i in range(M):
	L_max = max(L_max, L[i])
	R_min = min(R_min, R[i])

cnt = R_min - L_max + 1

if cnt < 0:
	print("0")
else:
	print(cnt) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] R = [] R [] for _ in range(M):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r) _ range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r L.append(l) L.append L append l R.append(r) R.append R append r L_max = 0 L_max 0 R_min = 100000 R_min 100000 for i in range(M):
	L_max = max(L_max, L[i])
	R_min = min(R_min, R[i]) i range(M) range M L_max = max(L_max, L[i]) L_max max(L_max, L[i]) max L_max L[i] L i R_min = min(R_min, R[i]) R_min min(R_min, R[i]) min R_min R[i] R i cnt = R_min - L_max + 1 cnt R_min - L_max + 1 R_min - L_max R_min L_max 1 if cnt < 0:
	print("0")
else:
	print(cnt) cnt < 0 cnt 0 print("0") print "0" print(cnt) print cnt R = [] [] R cnt = R_min - L_max + 1 R_min - L_max + 1 cnt L_max = 0 0 L_max R_min = min(R_min, R[i]) min(R_min, R[i]) R_min M = map(int, input().split()) map(int, input().split()) M L = [] [] L r = map(int, input().split()) map(int, input().split()) r N, M = map(int, input().split()) map(int, input().split()) N L_max = max(L_max, L[i]) max(L_max, L[i]) L_max R_min = 100000 100000 R_min l, r = map(int, input().split()) map(int, input().split()) l
N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)

L_max = 0
R_min = 100000

for i in range(M):
	L_max = max(L_max, L[i])
	R_min = min(R_min, R[i])

cnt = R_min - L_max + 1

if cnt < 0:
	print("0")
else:
	print(cnt)
