Dielectron production in pp and pA collisions at 4.9 GeV