n, m = map(int, input().split())
ml, mr = 0, n
for i in range(m):
    l, r = map(lambda x: int(x) - 1, input().split())
    ml = max(ml, l)
    mr = min(mr, r)
print(max(0, mr - ml + 1)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ml, mr = 0, n ml 0 mr n for i in range(m):
    l, r = map(lambda x: int(x) - 1, input().split())
    ml = max(ml, l)
    mr = min(mr, r) i range(m) range m l, r = map(lambda x: int(x) - 1, input().split()) l map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split r ml = max(ml, l) ml max(ml, l) max ml l mr = min(mr, r) mr min(mr, r) min mr r print(max(0, mr - ml + 1)) print max(0, mr - ml + 1) max 0 mr - ml + 1 mr - ml mr ml 1 l, r = map(lambda x: int(x) - 1, input().split()) map(lambda x: int(x) - 1, input().split()) l ml = max(ml, l) max(ml, l) ml ml, mr = 0, n 0 ml n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m mr = 0, n n mr r = map(lambda x: int(x) - 1, input().split()) map(lambda x: int(x) - 1, input().split()) r mr = min(mr, r) min(mr, r) mr
n, m = map(int, input().split())
ml, mr = 0, n
for i in range(m):
    l, r = map(lambda x: int(x) - 1, input().split())
    ml = max(ml, l)
    mr = min(mr, r)
print(max(0, mr - ml + 1))
