n, m = map(int, input().split())

min_l = 0
max_l = 10**6

for _ in range(m):
    L, R = map(int, input().split())
    min_l = max(min_l, L)
    max_l = min(max_l, R)

print(max_l - min_l + 1 if max_l - min_l + 1 > 0 else 0) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m min_l = 0 min_l 0 max_l = 10**6 max_l 10**6 10 6 for _ in range(m):
    L, R = map(int, input().split())
    min_l = max(min_l, L)
    max_l = min(max_l, R) _ range(m) range m L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R min_l = max(min_l, L) min_l max(min_l, L) max min_l L max_l = min(max_l, R) max_l min(max_l, R) min max_l R print(max_l - min_l + 1 if max_l - min_l + 1 > 0 else 0) print max_l - min_l + 1 if max_l - min_l + 1 > 0 else 0 max_l - min_l + 1 > 0 max_l - min_l + 1 max_l - min_l max_l min_l 1 0 max_l - min_l + 1 max_l - min_l max_l min_l 1 0 m = map(int, input().split()) map(int, input().split()) m min_l = 0 0 min_l min_l = max(min_l, L) max(min_l, L) min_l max_l = 10**6 10**6 max_l max_l = min(max_l, R) min(max_l, R) max_l L, R = map(int, input().split()) map(int, input().split()) L R = map(int, input().split()) map(int, input().split()) R n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())

min_l = 0
max_l = 10**6

for _ in range(m):
    L, R = map(int, input().split())
    min_l = max(min_l, L)
    max_l = min(max_l, R)

print(max_l - min_l + 1 if max_l - min_l + 1 > 0 else 0)