Alan bought 3 pencils and notebook. The notebook cost $6, and spent a total of $12. How much did each pencil cost? Use p to represent the cost of each pencil.