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