https://www.acmicpc.net/problem/9095
n=int(input())
arr=[0]*n
max=0
for i in range(n):
arr[i]=int(input())
if arr[i]>=max: max=arr[i]
if max<3: max=3
num=[0]*max
num[0]=1
num[1]=2
num[2]=4
for i in range(3,max):
num[i]=num[i-1]+num[i-2]+num[i-3]
for i in range(n):
print(num[arr[i]-1])