Write code to summarize time in each state.