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

lr = []

ming = 0
maxg = 10 **6

for i in range(m):
    a,b = map(int,input().split(" "))
    lr.append((a,b))

for i in lr:
    if i[0] > ming:
        ming = i[0]
    if i[1] < maxg:
        maxg = i[1]

print(max([0, maxg - ming + 1])) n,m = map(int,input().split(" ")) n map(int,input().split(" ")) map int input().split(" ") ().split () input split " " m lr = [] lr [] ming = 0 ming 0 maxg = 10 **6 maxg 10 **6 10 6 for i in range(m):
    a,b = map(int,input().split(" "))
    lr.append((a,b)) i range(m) range m a,b = map(int,input().split(" ")) a map(int,input().split(" ")) map int input().split(" ") ().split () input split " " b lr.append((a,b)) lr.append lr append (a,b) a b for i in lr:
    if i[0] > ming:
        ming = i[0]
    if i[1] < maxg:
        maxg = i[1] i lr if i[0] > ming:
        ming = i[0]
     i[0] > ming i[0] i 0 ming ming = i[0] ming i[0] i 0 if i[1] < maxg:
        maxg = i[1] i[1] < maxg i[1] i 1 maxg maxg = i[1] maxg i[1] i 1 print(max([0, maxg - ming + 1])) print max([0, maxg - ming + 1]) max [0, maxg - ming + 1] 0 maxg - ming + 1 maxg - ming maxg ming 1 lr = [] [] lr m = map(int,input().split(" ")) map(int,input().split(" ")) m ming = 0 0 ming b = map(int,input().split(" ")) map(int,input().split(" ")) b ming = i[0] i[0] ming n,m = map(int,input().split(" ")) map(int,input().split(" ")) n maxg = 10 **6 10 **6 maxg a,b = map(int,input().split(" ")) map(int,input().split(" ")) a maxg = i[1] i[1] maxg
n,m = map(int,input().split(" "))

lr = []

ming = 0
maxg = 10 **6

for i in range(m):
    a,b = map(int,input().split(" "))
    lr.append((a,b))

for i in lr:
    if i[0] > ming:
        ming = i[0]
    if i[1] < maxg:
        maxg = i[1]

print(max([0, maxg - ming + 1]))