#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define per(i, a, b) for(int i = a; i > (b); --i) #define ar array #define sz(x) (int) (x).size() #define pii pair #define fi first #define se second typedef long long ll; typedef pair pll; typedef pair pdd; typedef pair pdi; typedef vector vi; #define all(x) (x).begin(), (x).end() template void min_self(T& A, T B) { A = min(A,B); } template void max_self(T& A, T B) { A = max(A,B); } const int mxn=1e5; ll n; const ll mod = 1e9+7; // faster if const template struct Matrix { typedef Matrix M; array, N> d{}; M operator*(const M& m) const { M a; rep(i,0,N) rep(j,0,N) rep(k,0,N) a.d[i][j] = (a.d[i][j] + d[i][k]*m.d[k][j]%mod)%mod; return a; } vector operator*(const vector& vec) const { vector ret(N); rep(i,0,N) rep(j,0,N) ret[i] = (ret[i] + d[i][j] * vec[j]%mod)%mod; return ret; } M operator^(ll p) const { assert(p >= 0); M a, b(*this); rep(i,0,N) a.d[i][i] = 1; while (p) { if (p&1) a = a*b; b = b*b; p >>= 1; } return a; } }; void solve() { // vector fibo(10); // fibo[0] = 0, fibo[1] = 1; // rep(i,2,10) { // fibo[i] = fibo[i-1]+fibo[i-2]; // } // vector seq(10); // ll pr = 0; // rep(i,0,10) { // pr = (pr + fibo[i]*fibo[i])%mod; // seq[i] = pr; // cout <>n; ll n1 = mod-1; Matrix mat; mat.d = {{ {{2,2,n1}},{{1,0,0}} ,{{0,1,0}} }}; vector v = {2,1,0}; if(n<3) { cout <