const int maxn=3000000; ll inv[maxn+5]; void marktable_inv(int p){ inv[0]=inv[1]=1; for(int i=2;i<maxn;i++) inv[i]=(p-p/i)*inv[p%i]%p; }