Competing magnetic interactions in the intermetallic compounds Pr5Ge3 and Nd5Ge3