Barges from ports X and Y went to cities A and B. X sent 32 barges and Y sent 8. City A needs 22 barges and B needs 18. Shipping costs $220 from X to A, $300 from X to B, $400 from Y to A, and $180 from Y to B. $9280 was spent. How many barges went where?