Measurement of the Splitting Function in pp and Pb-Pb Collisions at sNN =5.02 TeV