Cody, Ethan and Tommy shared the cost of a souvenir. The ratio of Cody's share to the total share of Ethan and Tommy was 1 : 3. The ratio of Ethan's share to the total share of Cody and Tommy was 1 : 7. Ethan's share was $40 less than Tommy's share. How much did the souvenir cost?