Each child ticket for a ride costs $3, while each adult ticket costs $5. If the ride collected a total of $150, and 40 tickets were sold, how many of each type of ticket was sold?