Ishaan was playing with numbers. He knew how to calculate the sum of numbers. He defined a function for his use which calculates the **twice** sum of first N natural numbers as sum(N).

But being curious, he modified his function to calculate something more complex. He defined his function to be sumX(N,M,K).

Now this function calculates :

sum( K + sum( K + sum( K + ...sum(K + N)...))) , continuing for M terms (Refer example for explanation).

Given N, M and K, calculate the value of sumX(N,M,K).

Since the answer can be very large, print the answer in modulo 10^9 + 7.

**Input :**

First line of input contains a single integer T denoting the number of test cases.

The only line of each test case contains 3 space-separated integers N, M and K.

**Output : **

For each test case, print the required answer in a new line.

**Constraints : **

1 <= T <= 200

1 <= N <= 1000

1 <= M <= 1000

1 <= K <= 1000

**Example :
Input : **

3

1 2 3

2 2 2

3 3 2

552

506

1120422

**Explanation : **

Case 1 :

sum(3 + sum(3 + 1) ) = sum(3 + 20) = 552

Case 2 :

sum(2 + sum(2 + 2) ) = sum(2 + 20) = 506

Case 3 :

sum(2 + sum(2 + sum(2 + 3) ) ) = sum(2 + sum( 2 + 30 ) ) = sum(2 + 1056) = 1120422

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

saiujwal13083 | 347 |

isiddhisingh | 252 |

Abhishek_Jadhav | 243 |

_uncle_sam_ | 221 |

c_ocoooo | 217 |

saiujwal13083 | 610 |

SumitSingh27 | 466 |

c_ocoooo | 456 |

rathiarpit29 | 379 |

NaveenKumarNakka | 370 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.