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

LRs = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []

for LR in LRs:
    L.append(LR[0])
    R.append(LR[1])

print(max(min(R) - max(L) + 1, 0)) N,M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M list(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split LRs = [list(map(int, input().split())) for _ in range(M)] LRs [list(map(int, input().split())) for _ in range(M)] L = [] L [] R = [] R [] for LR in LRs:
    L.append(LR[0])
    R.append(LR[1]) LR LRs L.append(LR[0]) L.append L append LR[0] LR 0 R.append(LR[1]) R.append R append LR[1] LR 1 print(max(min(R) - max(L) + 1, 0)) print max(min(R) - max(L) + 1, 0) max min(R) - max(L) + 1 min(R) - max(L) min(R) min R max(L) max L 1 0 LRs = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] LRs M = list(map(int, input().split())) list(map(int, input().split())) M N,M = list(map(int, input().split())) list(map(int, input().split())) N L = [] [] L R = [] [] R
N,M = list(map(int, input().split()))

LRs = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []

for LR in LRs:
    L.append(LR[0])
    R.append(LR[1])

print(max(min(R) - max(L) + 1, 0))