n,m = map(int,input().split())
l,r = map(int,input().split())

for i in range(m-1):
    
    nl,nr = map(int,input().split())
    if l<nl :
        l = nl
    if r > nr:
        r = nr
print(max(r-l + 1, 0)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r for i in range(m-1):
    
    nl,nr = map(int,input().split())
    if l<nl :
        l = nl
    if r > nr:
        r = nr i range(m-1) range m-1 m 1 nl,nr = map(int,input().split()) nl map(int,input().split()) map int input().split() ().split () input split nr if l<nl :
        l = nl
     l<nl l nl l = nl l nl if r > nr:
        r = nr r > nr r nr r = nr r nr print(max(r-l + 1, 0)) print max(r-l + 1, 0) max r-l + 1 r-l r l 1 0 nl,nr = map(int,input().split()) map(int,input().split()) nl r = map(int,input().split()) map(int,input().split()) r m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n nr = map(int,input().split()) map(int,input().split()) nr l = nl nl l l,r = map(int,input().split()) map(int,input().split()) l r = nr nr r
n,m = map(int,input().split())
l,r = map(int,input().split())

for i in range(m-1):
    
    nl,nr = map(int,input().split())
    if l<nl :
        l = nl
    if r > nr:
        r = nr
print(max(r-l + 1, 0))
