#P7619. [2018年杭电多校]Sequence
[2018年杭电多校]Sequence
Sequence
Problem Description
Input
The first line has only one integer , indicates the number of tasks.
Then, for the next lines, each line consists of integers, , , , , , . $1 \leq T \leq 20 \\ 0 \leq A, B, C, D \leq 10^9 \\ 1 \leq P, n \leq 10^9$
Sample Input
2
3 3 2 1 3 5
3 2 2 2 1 4
Sample Output
36
24
Source
2018 Multi-University Training Contest 7