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