akash-and-loneliness

Akash is feeling lonely.So he decided to visit his friend's house.
His friend's house is located at the distance of K metres  from his
house.Now,he can take a step of one metre ,two metres or three 
metres  at a time.Can you tell me number of ways of reaching
Akash's friend house.
As the answer can be large Print  answer mod 1000000007

Input

First line contains an integer t  denoting number of test cases 
Next t lines contains an integer k 

Output

Print t lines containing number of ways to to reach  friend's house modulo 1000000007

SAMPLE INPUT
2
2
3

SAMPLE OUTPUT
2
4

Source: hackerearth | Difficulty: EASY
Tags: Dynamic programming


Solutions:
dis = list(range(1000000))
dis[0] = 1
dis[1] = 2
dis[2] = 4
for i in range(3 , 1000000):
	dis[i] = (dis[i-1] + dis[i-2] + dis[i-3])%1000000007	
	
t = int(input())
for _ in range(0,t):
	p = int(input())
	print(dis[p-1])