n=gets.to_i a=Array.new(n) b=Array.new(n) n.times{|i|a[i],b[i]=gets.split.map &:to_i} m=gets.to_i x=Array.new(m) y=Array.new(m) m.times{|j|x[j],y[j]=gets.split.map &:to_i} z=(0...m).map{|j|[j,(0...n).map{|i|x[j]<=a[i]&&y[j]>=b[i]?1:0}.sum]}.group_by{|k,v|v}.max_by{|k,v|k} z[0]>0?z[1].map{|k,v|p k+1}:(p 0)