#include #include using namespace std; using namespace atcoder; typedef modint1000000007 mint; typedef long long ll; mint Garner(vector m,vector r){ int n = m.size(); vector t(n); for(int i=0; i vector convolution_mint(vector a,vector b){ static constexpr unsigned long long M0 = 998244353; static constexpr unsigned long long M1 = 754974721; static constexpr unsigned long long M2 = 469762049; vector aa(a.size()),bb(b.size()); for(int i=0; i(aa,bb); auto c1 = convolution(aa,bb); auto c2 = convolution(aa,bb); vector ret(c0.size()); vector m = {M0,M1,M2}; for(int i=0; i r = {c0[i],c1[i],c2[i]}; vector t(3); for(int j=0; j<3; j++){ long long cur = 0LL; long long cm = 1LL; for(int k=0; k poly_inv(vector &a, int M = -314159265){ if (M == -314159265) M = (int)a.size(); else if (M <= 0) return {}; int n = a.size(); mint r = a[0].pow(mint::mod()-2); int m = 1; vector res = {r}; while (m < M){ vector f = a; f.resize(min(n, 2*m)); vector h = convolution_mint(f, res); for (int i=0; i multi_eval(vector x, vector a){ int n = x.size(); int siz = 1 << ceil_pow2(n); vector> g(2*siz, vector{1}); for (int i=0; i0; i--) g[i] = convolution_mint(g[2*i], g[2*i+1]); vector f; for (int i=1; i<2*siz; i++){ if (i==1) f = a; else f = g[i>>1]; int fs = f.size(), gs = g[i].size(); int m = fs - gs + 1; vector v = {}, w = {}; if (m > 0){ vector ft(m); for (int j=0; j gt(gs); for (int j=0; j 1 && g[i][g[i].size() - 1] == 0){ g[i].pop_back(); } } vector ret(n); for (int i=0; i> n; if (n >= mint::mod()){ cout << 0 << endl; return 0; } int m = pow(n, 0.5); deque> que; for (int i=0; i 1){ vector f = que.front(); que.pop_front(); vector g = que.front(); que.pop_front(); que.push_back(convolution_mint(f, g)); } vector f = que.front(); vector g(m); for (int i=0; i muleval = multi_eval(g, f); mint ans = 1; for (int i=m*m+1; i<=n; i++){ ans *= i; } for (int i=0; i