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