Find the pattern
##### Submissions: 466   Accuracy: 15.56%   Difficulty: Medium   Marks: 4

Mr TJ’s father owns a farm and wishes to sell his Apples. Mr TJ was asked by his father to visit the farm daily and tell him the number of apples that are good and ready to be sold. Mr. TJ’s father has already visited the farm twice and noted down the number of good apples to be 1 on each day. When Mr TJ goes to the farm, the third day he notices 7 good apples. On fourth day, he notices 19 good apples. Mr TJ, being a very lazy, tries to find a pattern in the number of apples.

1, 1, 7, 19, 73…
He soon realizes the pattern to be little bit similar to Fibonacci series. Mr. TJ does not want to go the farm daily and asked you to help. Mr TJ wants to calculate number of good apples on the nth day.

Input:
First line of input will contain an integer T, denoting the number of test cases. Each test case contains an integer n, denoting the nth day.

Output:
For each test case in a new line print the  number of good apples on the nth day.

Note: As the number of good apples may be very large, output the answer modulo 109+7.

Constraints
1<=T<=1000
1<=n<=109

Example:
Input:

5
1
2
3
4
5

Output:
1
1
7
19
73

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

Contributor: Rishabh Jain
Author: rishabh.jain9196

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.