#include using namespace std; #include using namespace boost::multiprecision; ////////////////////////////// // Check before you submit. //#define _ATCODER_LIBRARY const long long MOD = 1e9+7; // const long long MOD = 998244353; ///////////////////////////// #include using namespace std; #include using namespace boost::multiprecision; #ifdef _ATCODER_LIBRARY using namespace atcoder; #endif // _ATCODER_LIBRARY const long long INF = 1LL << 60; const double PI = acos(-1); using ll = long long; using P = array; #define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define SUM(v) accumulate(ALL(v),0ll) templateistream& operator>>(istream&i,vector&v){REP(j,v.size())i>>v[j];return i;} templatestring join(vector&v){stringstream s;REP(i,v.size())s<<' '<ostream& operator<<(ostream&o,vector&v){if(v.size())o<string join(vector>&vv){string s="\n";REP(i,vv.size())s+=join(vv[i])+"\n";return s;} templateostream& operator<<(ostream&o,vector>&vv){if(vv.size())o<istream& operator>>(istream&i,pair&v){return i>>v.first>>v.second;} templateostream& operator<<(ostream&o,pair&v){return o<<"("<istream& operator>>(istream&i,array&v){i>>v[0]>>v[1]; return i;} templateostream& operator<<(ostream&o,array&v){return o<<"("<T up(T a, T b){assert(b);return (a+b-1)/b;} templatebool eq(A const&... a){auto t={a...};assert(t.size());auto tar=*t.begin();for(const auto&e:t)if(tar!=e)return false;return true;} templateauto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector(arg,x);else return vector(arg,make_vector(x,args...));} templatebool chmin(T &a, T b){if(a>b){a=b;return true;}return false;} templatebool chmax(T &a, T b){if(abool chmax(T &a, initializer_listl){return chmax(a,max(l));} templatebool chmin(T &a, initializer_listl){return chmin(a,min(l));} ////////////////////////////////////////////////////////////////// // My Library ////////////////////////////////////////////////////////////////// template struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % mod) { if (val < 0) val += mod; } static long long inv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); } if (u<0)u+=m; return u; } constexpr int getmod() { return mod; } constexpr Fp operator - () const noexcept { return val ? mod - val : 0; } constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; } constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; } constexpr Fp& operator += (const Fp& r) noexcept { val += r.val; if (val >= mod) val -= mod; return *this; } constexpr Fp& operator -= (const Fp& r) noexcept { val -= r.val; if (val < 0) val += mod; return *this; } constexpr Fp& operator *= (const Fp& r) noexcept { val = val * r.val % mod; return *this; } constexpr Fp& operator /= (const Fp& r) noexcept { val = val * Fp::inv(r.val, mod) % mod; if (val < 0) val += mod; return *this; } constexpr bool operator == (const Fp& r) const noexcept { return this->val == r.val; } constexpr bool operator != (const Fp& r) const noexcept { return this->val != r.val; } friend constexpr ostream& operator << (ostream &os, const Fp& x) noexcept { return os << x.val; } friend constexpr Fp modpow(const Fp &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } friend constexpr Fp modfac(long long l, long long r) noexcept { auto res = Fp(1); for (Fp i = l; i < r; ++i) res *= i; return res; } }; using mint = Fp; ////////////////////////////////////////////////////////////////// // Contest Code ////////////////////////////////////////////////////////////////// mint solve(ll N) { mint n = (mint)N; mint res; if (n == 0) res = 1; else if (n == 1) res = 12; else if (n == 2) res = 65; else res = n*n*17 + n*6 + 1; return res; } int main(int argc, char **argv) { init_init_init(); ll N; cin >> N; std::cout << solve(N) << std::endl; }