# coding: utf-8
n, m = map(int,input().split())
r = float('inf')
l = 0
L = []
for i in range(m):
    l_, r_ = map(int,input().split())
    L.append([l_,r_])
    l = max(l_, l)
    r = min(r_, r)
ans = 0
print(max(0, r-l+1)) n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m r = float('inf') r float('inf') float 'inf' l = 0 l 0 L = [] L [] for i in range(m):
    l_, r_ = map(int,input().split())
    L.append([l_,r_])
    l = max(l_, l)
    r = min(r_, r) i range(m) range m l_, r_ = map(int,input().split()) l_ map(int,input().split()) map int input().split() ().split () input split r_ L.append([l_,r_]) L.append L append [l_,r_] l_ r_ l = max(l_, l) l max(l_, l) max l_ l r = min(r_, r) r min(r_, r) min r_ r ans = 0 ans 0 print(max(0, r-l+1)) print max(0, r-l+1) max 0 r-l+1 r-l r l 1 m = map(int,input().split()) map(int,input().split()) m r_ = map(int,input().split()) map(int,input().split()) r_ ans = 0 0 ans L = [] [] L l = 0 0 l n, m = map(int,input().split()) map(int,input().split()) n r = min(r_, r) min(r_, r) r l_, r_ = map(int,input().split()) map(int,input().split()) l_ r = float('inf') float('inf') r l = max(l_, l) max(l_, l) l
# coding: utf-8
n, m = map(int,input().split())
r = float('inf')
l = 0
L = []
for i in range(m):
    l_, r_ = map(int,input().split())
    L.append([l_,r_])
    l = max(l_, l)
    r = min(r_, r)
ans = 0
print(max(0, r-l+1))