N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for c in range(M):
    L[c], R[c] = map(int, input().split())

L_max = max(L)
R_min = min(R)

ans = R_min - L_max
ans += 1

if ans < 0:
    print(0)
else:
    print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [0] * M L [0] * M [0] 0 M R = [0] * M R [0] * M [0] 0 M for c in range(M):
    L[c], R[c] = map(int, input().split()) c range(M) range M L[c], R[c] = map(int, input().split()) L[c] L c map(int, input().split()) map int input().split() ().split () input split R[c] R c L_max = max(L) L_max max(L) max L R_min = min(R) R_min min(R) min R ans = R_min - L_max ans R_min - L_max R_min L_max ans += 1 ans 1 if ans < 0:
    print(0)
else:
    print(ans) ans < 0 ans 0 print(0) print 0 print(ans) print ans R = [0] * M [0] * M R R_min = min(R) min(R) R_min L_max = max(L) max(L) L_max M = map(int, input().split()) map(int, input().split()) M ans = R_min - L_max R_min - L_max ans ans += 1 1 ans N, M = map(int, input().split()) map(int, input().split()) N L = [0] * M [0] * M L
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for c in range(M):
    L[c], R[c] = map(int, input().split())

L_max = max(L)
R_min = min(R)

ans = R_min - L_max
ans += 1

if ans < 0:
    print(0)
else:
    print(ans)