A. Data Centers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
5 4
20 12 10 15 18
3 4
4 1
1 3
4 2
Output
11 10 10 9 8