n, m = map(int,input().split())
start = 1
end = n
for i in range(m):
    x, y = map(int,input().split())
    start = max(start, x)
    end = min(end, y)
print(end-start+1 if end-start >=0 else 0) n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m start = 1 start 1 end = n end n for i in range(m):
    x, y = map(int,input().split())
    start = max(start, x)
    end = min(end, y) i range(m) range m x, y = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y start = max(start, x) start max(start, x) max start x end = min(end, y) end min(end, y) min end y print(end-start+1 if end-start >=0 else 0) print end-start+1 if end-start >=0 else 0 end-start >=0 end-start end start 0 end-start+1 end-start end start 1 0 start = max(start, x) max(start, x) start end = min(end, y) min(end, y) end start = 1 1 start x, y = map(int,input().split()) map(int,input().split()) x m = map(int,input().split()) map(int,input().split()) m n, m = map(int,input().split()) map(int,input().split()) n y = map(int,input().split()) map(int,input().split()) y end = n n end
n, m = map(int,input().split())
start = 1
end = n
for i in range(m):
    x, y = map(int,input().split())
    start = max(start, x)
    end = min(end, y)
print(end-start+1 if end-start >=0 else 0)
