Lakshay can move Up(j, k) -> (j - 1, k), RIght(j, k) -> (j, k + 1) or Up-Right(j, k) -> (j - 1, k + 1).
Answers can be very large, so return the answer modulo 1000000007.
For Example :N = 2

For n = 2, there can be three possible moves, as shown in the figure. Hence the answer is 3.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first line of each test case contains a single integer ‘N’ denoting the size of the square matrix.
Output Format :
For each test case, print a single integer “ans” denoting the total number of paths.
Output for each test case will be printed in a separate line.
Note :
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 500
Time limit: 1 sec
2
3
2
13
3
In the first test case, There is a total of thirteen possible paths. Hence, the answer is 13.
In the second test case, There is a total of 3 possible paths. Hence, the answer is 3.
2
5
7
321
8989
Recursively call all the possible paths and return the final answer.
In this approach, we will start from the (N - 1, 0) and add all the possible paths for down, left, and down-left.
The steps are as follows:
O( 3 ^ N ), where N is the length of the square matrix.
As we are going through all the paths.
Hence the time complexity is O( 3 ^ N ).
O( 1 )
No extra space is used.
Hence the space complexity is O(1).