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