H. Payday Quest
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
4 3 3
1 1 1 1
1 2
1 1
2 2
5 1
3 1
6 3
1 3
2 8
3 1
2
5
1
8 1
4 1
1
9 2
1 1
2 4
Output
333333341
333333338
8
500000012