At least 39 people have been killed in Pakistan after days of unusually heavy rains battered the country's southwest.