N,M = map(int, input().split())

n = 0
m = 999999

for i in range(M):
  a,b = map(int, input().split())
  n = max(a, n)
  m = min(b , m)

print(max(m-n+1, 0)) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M n = 0 n 0 m = 999999 m 999999 for i in range(M):
  a,b = map(int, input().split())
  n = max(a, n)
  m = min(b , m) i range(M) range M a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b n = max(a, n) n max(a, n) max a n m = min(b , m) m min(b , m) min b m print(max(m-n+1, 0)) print max(m-n+1, 0) max m-n+1 m-n m n 1 0 n = 0 0 n n = max(a, n) max(a, n) n a,b = map(int, input().split()) map(int, input().split()) a m = 999999 999999 m m = min(b , m) min(b , m) m b = map(int, input().split()) map(int, input().split()) b 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())

n = 0
m = 999999

for i in range(M):
  a,b = map(int, input().split())
  n = max(a, n)
  m = min(b , m)

print(max(m-n+1, 0))
