BETA
K-Ary Tree
Submissions: 1914   Accuracy:

23.01%

  Difficulty: Easy
     

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


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