M hooks in a straight line are present on wall A and these are connected to N hooks (also in a straight line) on another wall B by means of ropes. There can be multiple number of ropes between any two hooks. Being bored and having nothing to do, little Murph takes K of these ropes and ties a knot (somehow! i.e. K of these ropes together forms a single knot, she doesn’t need the ropes to intersect to be able to tie them). Given the values of M, N, and K, can you help her figure out how many knots she can tie?

Assume walls to be of sufficient length to contain the given number of hooks.

Do not take into account a particular group of hooks more than once (there should be at least one different hook in any 2 groups). For example, let M=3, N=2, and K=2, and let hooks on Wall A be numbered as (A1, A2, A3) and on wall B as (B1, B2). Then joining A1 to B1 and A3 to B2 and tying a knot using these two ropes is same as joining A1 to B2 and A3 to B1 and tying a knot as both the groups (A1-B1, A3-B2) and (A1-B2, A3-B1) contains exactly same hooks.

But the groups (A1-B1, A3-B2), (A1-B1, A2-B2), (A2-B1, A3-B2) are all different.

**Input:**

The first line contains a single integer T denoting the number of test cases. Next T lines follow each of which contains 3 integers M, N and K as described in the problem.

**Output:**

For each test case, print in new line the number of knots little Murph can tie. Print your answer modulo 10^9 + 7.

**Constraints:**

1 <= T <= 1000

2 <= K, M, N <= 1000

K <= min(M, N)

**Example:
Input:**

2

4 3 3

4 3 2

**Output:**

4

18

**Explanation:**

The possible groups are (A1-B1, A2-B2, A3-B3), (A1-B1, A2-B2, A4-B3), (A1-B1, A3-B2, A4-B3), (A2-B1, A3-B2, A4-B3). Hence, she can tie 4 knots.

Other possible combination can be (A1-B3, A2-B1, A3-B2), (A1-B2, A2-B1, A4-B3), (A1-B3, A3-B2, A4-B1), (A2-B2, A3-B1, A4-B3).

Author: sajalagrawal

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.

vkpm | 22 |

Phenix_Fire | 18 |

shubhangi_upasani | 18 |

sajnanair | 16 |

EshaAgarwal | 16 |

Pulkit__Sharma__ | 806 |

Anirban166 | 682 |

Found_me | 616 |

abducodes | 607 |

Sathvik Avasarala | 518 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.