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

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

print(max(min(R) - max(L) + 1, 0)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] R = [] R [] for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(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) L.append L append l R.append(r) R.append R append r print(max(min(R) - max(L) + 1, 0)) print max(min(R) - max(L) + 1, 0) max min(R) - max(L) + 1 min(R) - max(L) min(R) min R max(L) max L 1 0 l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r M = map(int, input().split()) map(int, input().split()) M L = [] [] L R = [] [] R N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

print(max(min(R) - max(L) + 1, 0))