Dielectron production in proton-proton and proton-lead collisions at sNN =5.02 TeV