N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    tmp = list(map(int, input().split()))
    L.append(tmp[0])
    R.append(tmp[1])

ans = min(R) - max(L) + 1
if ans < 0: ans = 0
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] R = [] R [] for i in range(M):
    tmp = list(map(int, input().split()))
    L.append(tmp[0])
    R.append(tmp[1]) i range(M) range M tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.append(tmp[0]) L.append L append tmp[0] tmp 0 R.append(tmp[1]) R.append R append tmp[1] tmp 1 ans = min(R) - max(L) + 1 ans min(R) - max(L) + 1 min(R) - max(L) min(R) min R max(L) max L 1 if ans < 0: ans = 0 ans < 0 ans 0 print(ans) print ans tmp = list(map(int, input().split())) list(map(int, input().split())) tmp M = map(int, input().split()) map(int, input().split()) M L = [] [] L ans = min(R) - max(L) + 1 min(R) - max(L) + 1 ans N, M = map(int, input().split()) map(int, input().split()) N R = [] [] R
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    tmp = list(map(int, input().split()))
    L.append(tmp[0])
    R.append(tmp[1])

ans = min(R) - max(L) + 1
if ans < 0: ans = 0
print(ans)