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

L = [None] * M
R = [None] * M

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

L_max = max(L)
R_min = min(R)

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

L = [None] * M
R = [None] * M

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

L_max = max(L)
R_min = min(R)

if L_max > R_min:
    print(0)
else:
    print(R_min - L_max + 1)
