A man was travelling half of the total distance at a speed of 30 km/h and the rest distance at a speed of 50 km/h. What was the average speed of the man on his whole journey?