#include using namespace std; typedef long long ll; template bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} typedef vector vec; typedef vector mat; ll mod=1e9+7; mat mul(mat &a,mat&b){ mat c(a.size(),vec(b[0].size())); for (int i = 0; i < a.size(); i++){ for (int k = 0; k < b.size(); k++){ for (int j = 0; j < b[0].size(); j++){ c[i][j]=(c[i][j] + a[i][k] * b[k][j]) %mod; } } } return c; } mat matpow(mat a,ll m){ mat b(a.size(),vec(a.size())); for (int i = 0; i < a.size(); i++){ b[i][i]=1; } while(m>0){ if(m&1) b=mul(b,a); a=mul(a,a); m>>=1; } return b; } ll calc(mat A, ll m){ A = matpow(A,m); return A[0][0]; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); /* // めっちゃ雑にやることを考える int dp[k][m]={}; dp[0][0]=1; // O(k*m^2) for(int i=0;i>m>>k; mat A(m,vec(m)); for(int i=0;i