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