ICPC 2022 Online Challenge powered by HUAWEI - Problem 2


A. Topology-Aware VM Placement
time limit per test: 15 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2 2
8 16
8 16
3
1 1 1
1 4 2
2 4 8
1
1 4 1
1 0
2
3 1 1 1
1 2 3
2
3 1 1 1
4 5 6
1
2 0 0
2 2
2
3 3 2 0
7 8 9
3
3 3 5 6
2
2 3 1 4
10 11
2
2 3 1 3
12 13
4
Output
1 1 1 1
1 1 2 1
1 2 1 1
2 1 1 1
2 1 2 1
2 2 1 1
1 2 1 1 2
1 2 2 1 2
1 2 2 1 2
2 2 1 1 2
2 2 2 1 2
-1
----------------------------------------------------------------------------------------------------
