On the occasion of your birthday, your friends have organized a surprise birthday party for you. In that party, there is a game planned by them. Rules of the game are as follows:-
Can you find this minimum cost? The number may be large, so print the value modulo 109+7.
Input Format:
The first line contains an integer q, the number of input queries.
The following q sets of lines are as follows:
The first line has two positive space-separated integers m and n, the number of rows and columns on the cake.
The second line contains m−1 space-separated integers cost_y[i], the cost of a horizontal cut between rows i, and i+1 of the cake.
The third line contains n−1 space-separated integers cost_x[j], the cost of a vertical cut between columns jand j+1 of the cake.
Output Format:
For each of the q queries, find the minimum cost of cutting the cake into 1×1 squares and print the value of this cost module 109+7
Constraints:
1≤q≤200
2≤m,n≤100000
0≤cost_x[j],cost_y[i]≤109
Our sequence of cuts is: y[5],x[1],y[3],y[1],x[3],y[2],y[4],x[2]
Total cost=4+8+6+4+8+3+3+6=42. We then print the value of 42 % (109+7)