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