Let T be the number of T-shirts sold, so 8T is the cost of production.
Total sales is 20(T-10)=20T-200 because 10 shirts were given away for free.
Total profit is $304=20T-200-8T=12T-200; 12T=504, T=42 sold, including the giveaways.
CHECK
10 were given away so only 32 were sold, sales=20×32=$640.
42 were made, costing 8×42=$336.
Profit=640-336=$304.