N, M = map(int, input().split())
lefts = []
rights = []

for _ in range(M):
    L, R = map(int, input().split())
    lefts.append(L)
    rights.append(R)

lefts.sort()
rights.sort()

if lefts[-1] > rights[0]:
    print(0)
else:
    print(rights[0] - lefts[-1] + 1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M lefts = [] lefts [] rights = [] rights [] for _ in range(M):
    L, R = map(int, input().split())
    lefts.append(L)
    rights.append(R) _ range(M) range M L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R lefts.append(L) lefts.append lefts append L rights.append(R) rights.append rights append R lefts.sort() lefts.sort lefts sort rights.sort() rights.sort rights sort if lefts[-1] > rights[0]:
    print(0)
else:
    print(rights[0] - lefts[-1] + 1) lefts[-1] > rights[0] lefts[-1] lefts -1 rights[0] rights 0 print(0) print 0 print(rights[0] - lefts[-1] + 1) print rights[0] - lefts[-1] + 1 rights[0] - lefts[-1] rights[0] rights 0 lefts[-1] lefts -1 1 L, R = map(int, input().split()) map(int, input().split()) L R = map(int, input().split()) map(int, input().split()) R rights = [] [] rights N, M = map(int, input().split()) map(int, input().split()) N lefts = [] [] lefts M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
lefts = []
rights = []

for _ in range(M):
    L, R = map(int, input().split())
    lefts.append(L)
    rights.append(R)

lefts.sort()
rights.sort()

if lefts[-1] > rights[0]:
    print(0)
else:
    print(rights[0] - lefts[-1] + 1)
