A bakery sold apple pies for $12 and blueberry pies for $14. One Saturday they sold a total of 41 pies and collected a total of $536. How many apple pies did they sell and how many blueberry pies did they sell?