N,M=map(int,input().split())
L=-10**9
R=+10**9
for _ in range(M):
    l,r=map(int,input().split())
    L=max(L,l)
    R=min(R,r)
print(max(0,R-L+1)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M L=-10**9 L -10**9 -10 9 R=+10**9 R +10**9 10**9 10 9 for _ in range(M):
    l,r=map(int,input().split())
    L=max(L,l)
    R=min(R,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=max(L,l) L max(L,l) max L l R=min(R,r) R min(R,r) min R r print(max(0,R-L+1)) print max(0,R-L+1) max 0 R-L+1 R-L R L 1 l,r=map(int,input().split()) map(int,input().split()) l L=-10**9 -10**9 L M=map(int,input().split()) map(int,input().split()) M R=+10**9 +10**9 R R=min(R,r) min(R,r) R r=map(int,input().split()) map(int,input().split()) r L=max(L,l) max(L,l) L N,M=map(int,input().split()) map(int,input().split()) N
N,M=map(int,input().split())
L=-10**9
R=+10**9
for _ in range(M):
    l,r=map(int,input().split())
    L=max(L,l)
    R=min(R,r)
print(max(0,R-L+1))