Himachal Pradesh assembly polls: Congress wins 40 seats; wrests power from BJP