ICPC Challenge 2021: Marathon (powered by Huawei)


A. Balanced Regions
time limit per test: 20 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
4 2 3 1 1
1 3
4
1 2
1 3
2 4
3 4
Output
2 1 2
3
2 1 4
1 2
1 3
----------------------------------------------------------------------------------------------------
