K-Ary Tree
Submissions: 2284   Accuracy:

26.55%

  Difficulty: Easy   Marks: 2

Find the number of leaf nodes in a full k-ary tree of height m.

Input:
First line contains an integer T, number of test cases. Each line of the test case contains two integer k and m.

Output:
Print the number of leafs under modulo 10^9+7.

Constraints:
1<=T<=10^4
1<=k<=100
0<=m<=1000

Example:
Input

1
2 2
Output:
4

Explanation:
A full Binary tree of height 2 has 4 leaf nodes.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: ShivamKD
Author: Dharmesh


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.