9 books are to be bought by a student. Some cost $6 and the remainder cost $3 each. if the total amount spent was $39, how many of each are bought?
Please explain your answer.