#include std::vector> matrix_product(std::vector> A,std::vector>B,const int64_t mod) { int64_t AH=A.size(),AW=A[0].size(),BH=B.size(),BW=B[0].size(); assert(AW==BH); std::vector> C(AH,std::vector (BW)); for(int i=0;i>1; } return res; } int64_t fibonacci(int64_t N,const int64_t mod) { if(N==0) { return 0; } N--; std::vector> F(2,std::vector (1)),A(2,std::vector (2)),B; F[0][0]=1,F[1][0]=0; A[0][0]=1,A[0][1]=1,A[1][0]=1,A[1][1]=0; B=A; while(0>=1; } return matrix_product(A,F,mod)[1][0]; } int main() { int64_t N,M; std::cin>>N>>M; N--; std::cout<