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

L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

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 = [0] * M L [0] * M [0] 0 M R = [0] * M R [0] * M [0] 0 M for i in range(M):
    L[i], R[i] = map(int, input().split()) i range(M) range M L[i], R[i] = map(int, input().split()) L[i] L i map(int, input().split()) map int input().split() ().split () input split R[i] R i 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 R = [0] * M [0] * M R N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M L = [0] * M [0] * M L
N, M = map(int, input().split())

L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

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