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