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

llist = []
rlist = []
for i in range(m):
    l,r = map(int,input().split())
    llist += [l]
    rlist += [r]

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

llist = []
rlist = []
for i in range(m):
    l,r = map(int,input().split())
    llist += [l]
    rlist += [r]

print(max(0,min(rlist)-max(llist)+1))
