n, m = list(map(int, input().split()))

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

ans =[0] * (n + 1)



for l, r in LR:

  ans[l - 1] += 1

  ans[r] -= 1

  

accu =[0] * (n + 1)

for i in range(n):

  accu[i + 1] += ans[i] + accu[i]

  

ans = accu.count(m)



print(ans)
n, m = list(map(int, input().split()))

L = []

R = []

for _ in range(m):

  l, r = list(map(int, input().split()))

  L.append(l)

  R.append(r)

  

ans = max(0, min(R) - max(L) + 1)



print(ans)



n, m = list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(m)]
ans = [0] * (n + 1)
for l, r in LR:
    ans[l - 1] += 1
    ans[r] -= 1
accu = [0] * (n + 1)
for i in range(n):
    accu[i + 1] += ans[i] + accu[i]
ans = accu.count(m)
print(ans)

n, m = list(map(int, input().split()))
L = []
R = []
for _ in range(m):
    l, r = list(map(int, input().split()))
    L.append(l)
    R.append(r)
ans = max(0, min(R) - max(L) + 1)
print(ans)

-LR = [list(map(int, input().split())) for _ in range(m)] -ans = [0] * (n + 1) -for l, r in LR: -    ans[l - 1] += 1 -    ans[r] -= 1 -accu = [0] * (n + 1) -for i in range(n): -    accu[i + 1] += ans[i] + accu[i] -ans = accu.count(m) +L = [] +R = [] +for _ in range(m): +    l, r = list(map(int, input().split())) +    L.append(l) +    R.append(r) +ans = max(0, min(R) - max(L) + 1)