The school store sells Midville High T-shirts for $12 each and Midville High gym shorts for $9 a pair. One afternoon they sold a total of 39 T-shirts and pairs of shorts for a total of $414 . How many T-shirts did they sell and how many pairs of shorts did they sell?