N,M = map(int, input().split())

Lm = -1
Rm = float('inf')

for _ in range(M):
    L,R = map(int, input().split())
    Lm = max(L, Lm)
    Rm = min(R, Rm)

print(max(Rm - Lm + 1, 0)) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M Lm = -1 Lm -1 Rm = float('inf') Rm float('inf') float 'inf' for _ in range(M):
    L,R = map(int, input().split())
    Lm = max(L, Lm)
    Rm = min(R, Rm) _ range(M) range M L,R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R Lm = max(L, Lm) Lm max(L, Lm) max L Lm Rm = min(R, Rm) Rm min(R, Rm) min R Rm print(max(Rm - Lm + 1, 0)) print max(Rm - Lm + 1, 0) max Rm - Lm + 1 Rm - Lm Rm Lm 1 0 L,R = map(int, input().split()) map(int, input().split()) L Rm = min(R, Rm) min(R, Rm) Rm M = map(int, input().split()) map(int, input().split()) M N,M = map(int, input().split()) map(int, input().split()) N R = map(int, input().split()) map(int, input().split()) R Lm = max(L, Lm) max(L, Lm) Lm Rm = float('inf') float('inf') Rm Lm = -1 -1 Lm
N,M = map(int, input().split())

Lm = -1
Rm = float('inf')

for _ in range(M):
    L,R = map(int, input().split())
    Lm = max(L, Lm)
    Rm = min(R, Rm)

print(max(Rm - Lm + 1, 0))