#K36197. Project State Duration Accumulation

    ID: 25701 Type: Default 1000ms 256MiB

Project State Duration Accumulation

Project State Duration Accumulation

You are given a series of log entries representing state changes for different projects. Each log entry contains three fields: a project ID, a state name, and a duration (which can be negative). The input ends when a line containing only end is encountered.

Your task is to accumulate the total duration each project has spent in each state. For each project, sum the durations for every state while preserving the order in which states first appear for that project. Finally, output the result for each project on a new line, sorted in ascending order by the project ID.

The output format for each project should be as follows:

project_id state1:duration1 state2:duration2 ...

For example, given the input:

1 Planning 3
1 Development 5
2 Planning 2
1 Testing 1
2 Development 7
3 Planning 4
3 Testing 1
end

The correct output is:

1 Planning:3 Development:5 Testing:1
2 Planning:2 Development:7
3 Planning:4 Testing:1

Note: If a state appears multiple times for the same project, the durations should be summed up. Use standard input (stdin) for reading input and standard output (stdout) for printing the result.

inputFormat

The input consists of multiple lines. Each line (except the termination line) is in the format:

project_id state_name duration

The input terminates with a line containing only end.

outputFormat

For each project, output one line containing the project id followed by the states and their corresponding accumulated durations. Each state record is printed in the format:

state:duration

Projects must be printed in ascending order of project ID and each project's states should appear in the order of their first occurrence in the input.

## sample
1 Planning 3
1 Development 5
end
1 Planning:3 Development:5

</p>