BETA

Difficulty Level: Easy

Submissions: 1051 Accuracy:

17.32%

[K-Ary Tree]
     

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

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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