#include #define MOD 17 using namespace std; typedef long long ll; typedef pair P; typedef vector vec; typedef vector mat; mat mul(mat &A,mat &B){ mat C(A.size(),vec(B[0].size())); for(int i=0;i0){ if(n&1LL)B=mul(B,A); A=mul(A,A); n>>=1LL; } return B; } int main(void){ int q; scanf("%d",&q); for(int i=0;i0)A[i][i-1]=1; } for(int i=0;i<4;i++){ A[0][i]=1; } A=pow(A,n-4LL); printf("%d\n",A[0][0]); } return 0; }