#include #include #include #define rep(i,a) for(int i=0;i<(a);++i) typedef long long ll; const ll mod = 1000000007; int T; ll fact[1000001]; ll extgcd( ll a, ll b, ll &x, ll &y ) { int d = b; if( b ) { d = extgcd( b, a%b, y, x ); y -= a/b*x; } else x = 1, y = 0; return d; } ll divMod( ll a, ll b, ll m ) { ll x, y; extgcd( b, m, x, y ); return ((a*x)%m+m)%m; } ll perm( int n, int r ) { return n