45th ICPC World Finals Challenge powered by Huawei - Problem 2


A. Task Scheduling and Data Assignment
time limit per test: 15 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6
1 40 6 2 1 2
2 20 6 2 1 2
3 96 10 2 1 2
4 20 6 2 1 2
5 60 0 2 1 2
6 20 0 1 1
2
1 1
2 2
2
1 1 30
2 2 17
8
1 2
1 3
1 4
2 4
2 5
3 5
3 6
4 6
1
1 5
Output
1  0  2  2
2 23  1  1
3 23  2  2
4 52  1  1
5 79  2  1
6 87  1  2
----------------------------------------------------------------------------------------------------
