For Times Square magnets, we have that the price of each magnet is 2 dollars / magnet, there are 4 magnets / set, and Tom buys 12 sets. For Statue of Liberty magnets, the price is 3 dollars / magnet, there are 5 magnets / set, and Tom buys 12 sets
We can make a table of these values: 
 
Magnets Price ($$/magnets) Set Size (magnets/set) Quantity (sets)
T.S. 2 4 12
S. of L. 3 5 12
 
Now, we can use the formula 
 
Total Cost = Number of Magnets Bought * Price = (Quantity * Set Size) * Price
 
So we see that
 
Cost of T.S. magnets = Quantity * Set Size * Price
 = 12 sets * 4 magnets * 2 dollars = $96
 set magnet
 
Cost of S. of L. magnets = Quantity * Set Size * Price
 = 12 sets * 5 magnets * 3 dollars = $180
 set magnet
 
So the total amount spent was $96 + $180 = $276.