#include #include #include #include using namespace std; using i64 = int64_t; constexpr static int mod = static_cast(pow(10, 9)) + 7; i64 mod_inv(i64 a, i64 m) { i64 b = m, s = 1, t = 0, old_a = a; while(b) { i64 q = a / b; swap(a %= b, b); swap(s -= t * q, t); } if(a != 1) { assert(0); } return s < 0 ? s + m : s; } class Comb { private: int N; public: explicit Comb(int N); vector fac; // fac[x] := x! % mod i64 P(int n, int k); i64 C(int n, int k); i64 H(int n, int k); }; Comb::Comb(int N_) : N(N_) { fac.resize(N+1); fac[0] = 1; for(int i=0; i &a) { Comb comb(n-1); i64 res = 0; for(int i=0; i a(N); for(int i=0; i