n,m = map(int,input().split())
lmax, rmin = 0, n

for _ in range(m):
  l,r = map(int,input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)

print((rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lmax, rmin = 0, n lmax 0 rmin n for _ in range(m):
  l,r = map(int,input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r) _ range(m) range m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r lmax = max(lmax, l) lmax max(lmax, l) max lmax l rmin = min(rmin, r) rmin min(rmin, r) min rmin r print((rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0) print (rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0 (rmin-lmax)+1 > 0 (rmin-lmax)+1 rmin-lmax rmin lmax 1 0 (rmin-lmax)+1 rmin-lmax rmin lmax 1 0 n,m = map(int,input().split()) map(int,input().split()) n lmax, rmin = 0, n 0 lmax rmin = 0, n n rmin rmin = min(rmin, r) min(rmin, r) rmin lmax = max(lmax, l) max(lmax, l) lmax m = map(int,input().split()) map(int,input().split()) m r = map(int,input().split()) map(int,input().split()) r l,r = map(int,input().split()) map(int,input().split()) l
n,m = map(int,input().split())
lmax, rmin = 0, n

for _ in range(m):
  l,r = map(int,input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)

print((rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0)