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

for i in range(m):
    l_t,r_t = map(int,input().split())
    l.append(l_t)
    r.append(r_t)

print(max(min(r)-max(l)+1,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_t,r_t = map(int,input().split())
    l.append(l_t)
    r.append(r_t) i range(m) range m l_t,r_t = map(int,input().split()) l_t map(int,input().split()) map int input().split() ().split () input split r_t l.append(l_t) l.append l append l_t r.append(r_t) r.append r append r_t print(max(min(r)-max(l)+1,0)) print max(min(r)-max(l)+1,0) max min(r)-max(l)+1 min(r)-max(l) min(r) min r max(l) max l 1 0 l_t,r_t = map(int,input().split()) map(int,input().split()) l_t n,m = map(int,input().split()) map(int,input().split()) n r = [] [] r r_t = map(int,input().split()) map(int,input().split()) r_t m = map(int,input().split()) map(int,input().split()) m l = [] [] l
n,m = map(int,input().split())
l = []
r = []

for i in range(m):
    l_t,r_t = map(int,input().split())
    l.append(l_t)
    r.append(r_t)

print(max(min(r)-max(l)+1,0))
