n,m = map(int,input().split())
L = []
R = []
for _ in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

print (max(0,min(R)-max(L)+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 _ in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r) _ range(m) range m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r L.append(l) L.append L append l R.append(r) R.append R append r print (max(0,min(R)-max(L)+1)) print max(0,min(R)-max(L)+1) max 0 min(R)-max(L)+1 min(R)-max(L) min(R) min R max(L) max L 1 L = [] [] L R = [] [] R r = map(int,input().split()) map(int,input().split()) r n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m l,r = map(int,input().split()) map(int,input().split()) l
n,m = map(int,input().split())
L = []
R = []
for _ in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

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