Sam, Michael and Dylan shared the cost of a gift. The ratio of Sam's share to the total share of Michael and Dylan was 1 : 4. The ratio of Michael's share to the total share of Sam and Dylan was 1 : 6. Michael's share was $162 less than Dylan's share. How much did the gift cost?