N,M=map(int,input().split())
Lmax = 0
Rmin = 1e8
for _ in range(M):
    L,R=map(int,input().split())
    if L > Lmax:
        Lmax = L
    if R < Rmin:
        Rmin = R

print(max(0, Rmin - Lmax + 1)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M Lmax = 0 Lmax 0 Rmin = 1e8 Rmin 1e8 for _ in range(M):
    L,R=map(int,input().split())
    if L > Lmax:
        Lmax = L
    if R < Rmin:
        Rmin = R _ range(M) range M L,R=map(int,input().split()) L map(int,input().split()) map int input().split() ().split () input split R if L > Lmax:
        Lmax = L
     L > Lmax L Lmax Lmax = L Lmax L if R < Rmin:
        Rmin = R R < Rmin R Rmin Rmin = R Rmin R print(max(0, Rmin - Lmax + 1)) print max(0, Rmin - Lmax + 1) max 0 Rmin - Lmax + 1 Rmin - Lmax Rmin Lmax 1 Rmin = 1e8 1e8 Rmin Rmin = R R Rmin Lmax = L L Lmax R=map(int,input().split()) map(int,input().split()) R L,R=map(int,input().split()) map(int,input().split()) L N,M=map(int,input().split()) map(int,input().split()) N M=map(int,input().split()) map(int,input().split()) M Lmax = 0 0 Lmax
N,M=map(int,input().split())
Lmax = 0
Rmin = 1e8
for _ in range(M):
    L,R=map(int,input().split())
    if L > Lmax:
        Lmax = L
    if R < Rmin:
        Rmin = R

print(max(0, Rmin - Lmax + 1))