N,M=map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = input().split()
    L.append(int(l))
    R.append(int(r))


x = min(R)-max(L)


print(0 if x <0 else x+1) 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):
    l, r = input().split()
    L.append(int(l))
    R.append(int(r)) i range(M) range M l, r = input().split() l input().split() ().split () input split r L.append(int(l)) L.append L append int(l) int l R.append(int(r)) R.append R append int(r) int r x = min(R)-max(L) x min(R)-max(L) min(R) min R max(L) max L print(0 if x <0 else x+1) print 0 if x <0 else x+1 x <0 x 0 0 x+1 x 1 r = input().split() input().split() r l, r = input().split() input().split() l L = [] [] L M=map(int, input().split()) map(int, input().split()) M x = min(R)-max(L) min(R)-max(L) x 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):
    l, r = input().split()
    L.append(int(l))
    R.append(int(r))


x = min(R)-max(L)


print(0 if x <0 else x+1)