David and Emma are collecting donations for a charity event. They agreed that David would collect three times as much money as Emma. If the total amount collected by both of them is $400, how much did each of them collect? Let's think step by step and output the final answer within \boxed{}.
user