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

L_max = 0
R_min = N

for i in range(M):
    L, R = map(int, input().split())
    R_min = min(R,R_min)
    L_max = max(L,L_max)

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

L_max = 0
R_min = N

for i in range(M):
    L, R = map(int, input().split())
    R_min = min(R,R_min)
    L_max = max(L,L_max)

print(max(R_min-L_max+1,0))