#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long ll; typedef pair P; const ll MOD=1e9+7; ll powmod(ll a, ll k){ ll ap=a, ans=1; while(k){ if(k&1){ ans*=ap; ans%=MOD; } ap=ap*ap; ap%=MOD; k>>=1; } return ans; } ll inv(ll a){ return powmod(a, MOD-2); } vector> matrixmul(int l, int m, int n, vector> a, vector> b){ vector> c(l, vector(n)); for(int i=0; i> matrixpow(int n, vector> a, ll k){ vector> ap=a, ans(n, vector(n)); for(int i=0; i>=1; } return ans; } int main() { ll p; cin>>p; ll v=inv((p*p+4)%MOD); int q; cin>>q; ll a[2000020], b[2000020]; a[1]=0, a[2]=1; for(int i=3; i<=2000000; i++){ a[i]=(p*a[i-1]+a[i-2])%MOD; } b[0]=2, b[1]=p; for(int i=2; i<=2000000; i++){ b[i]=(p*b[i-1]+b[i-2])%MOD; } for(int i=0; i>x; cout<<((ll)(x-1)*b[x-2]%MOD-2*a[x]%MOD+MOD)*v%MOD<