#include <iostream>
using namespace std;
// 9095 123 더하기
// Created by polcom, 230307
int func(int n){
if (n<0) return 0;
else if(n==0) return 1;
else return (func(n-1)+ func(n-2) + func(n-3));
}
int main(){
int T=0;
cin >> T;
int res[T+1];
for(int t=0; t<T; t++){
int N = 0;
cin >> N;
for (int n = 1; n<=N; n++){
res[t]=func(n);
// cout << "temp" << res[t] << endl;
}
// cout << "e" << endl;
}
for(int t=0; t<T; t++){
cout << res[t] << endl;
}
return 0;
}