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

mn = 0
mx = 10**6

for i in range(M):
    l, r = map(int, input().split())
    mn = max(l, mn)
    mx = min(r, mx)

result = max(0, mx - mn + 1)
print(result) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M mn = 0 mn 0 mx = 10**6 mx 10**6 10 6 for i in range(M):
    l, r = map(int, input().split())
    mn = max(l, mn)
    mx = min(r, mx) i range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r mn = max(l, mn) mn max(l, mn) max l mn mx = min(r, mx) mx min(r, mx) min r mx result = max(0, mx - mn + 1) result max(0, mx - mn + 1) max 0 mx - mn + 1 mx - mn mx mn 1 print(result) print result M = map(int, input().split()) map(int, input().split()) M r = map(int, input().split()) map(int, input().split()) r result = max(0, mx - mn + 1) max(0, mx - mn + 1) result mn = 0 0 mn mx = 10**6 10**6 mx l, r = map(int, input().split()) map(int, input().split()) l N, M = map(int, input().split()) map(int, input().split()) N mn = max(l, mn) max(l, mn) mn mx = min(r, mx) min(r, mx) mx
N, M = map(int, input().split())

mn = 0
mx = 10**6

for i in range(M):
    l, r = map(int, input().split())
    mn = max(l, mn)
    mx = min(r, mx)

result = max(0, mx - mn + 1)
print(result)
