N, M = list(map(int, input().split()))
L, R = 0, N + 1
for i in range(M):
	l, r = list(map(int, input().split()))
	L = max(L, l)
	R = min(R, r)
print(max(R - L + 1, 0)) N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M L, R = 0, N + 1 L 0 R N + 1 N 1 for i in range(M):
	l, r = list(map(int, input().split()))
	L = max(L, l)
	R = min(R, r) i range(M) range M l, r = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split r L = max(L, l) L max(L, l) max L l R = min(R, r) R min(R, r) min R r print(max(R - L + 1, 0)) print max(R - L + 1, 0) max R - L + 1 R - L R L 1 0 L, R = 0, N + 1 0 L M = list(map(int, input().split())) list(map(int, input().split())) M R = min(R, r) min(R, r) R R = 0, N + 1 N + 1 R N, M = list(map(int, input().split())) list(map(int, input().split())) N r = list(map(int, input().split())) list(map(int, input().split())) r l, r = list(map(int, input().split())) list(map(int, input().split())) l L = max(L, l) max(L, l) L
N, M = list(map(int, input().split()))
L, R = 0, N + 1
for i in range(M):
	l, r = list(map(int, input().split()))
	L = max(L, l)
	R = min(R, r)
print(max(R - L + 1, 0))
