J. Reservoir Doggos
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
2
1
123
456
3
6 24 30
14 36 60
Output
56088
4404