#include #include #include #include #include #include #include #include #include //#include #define fi first #define se second #define pb(x) emplace_back(x) using namespace std; using ll = long long; using v_ll = vector ; bool IS_TEST=false; ll INF = ll(1e17); ll max(ll x,ll y){return x>y?x:y;} ll min(ll x,ll y){return x bool chmax(T& x,const T& y){ if (x>=y) return false; x=y; return true;} template bool chmin(T& x,const T& y){ if (x<=y) return false; x=y; return true;} template void quit(T x){std::cout << x << "\n"; exit(0);} template void vshow(T x){for(auto itr = x.begin();itr!=x.end();itr++){std::cerr << *itr << " ";} std::cerr << "\n";} template void vvshow(T x){for(auto itr = x.begin();itr!=x.end();itr++){vshow(*itr);} std::cerr << "\n";} int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll N; cin >> N; if (N==0) cout << 1 << "\n"; else if (N==1) cout << 12 << "\n"; else if (N==2) cout << 65 << "\n"; else cout << ((17LL*N%1000000007LL*N%1000000007LL+6*N+1)%1000000007LL) << "\n"; }