#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(x) (int)(x).size()
#define fastio cin.tie(0) -> sync_with_stdio(0)
#define DEBUG 0
#define pii pair<int, int>
#define ll long long
#define C 31
#define F(i, a, b) for(int i=(a); i <= (b); ++i)
#define SUM 1
#define MAX 0
#define SINGLE 1
#define szt size_t
#define YES cout << "YES\n";
#define NO cout << "NO\n";

//jiangly Codeforces
constexpr int P = 998244353;
using i64 = long long;
// assume -P <= x < 2P
int norm(int x) {
    if (x < 0) {
        x += P;
    }
    if (x >= P) {
        x -= P;
    }
    return x;
}
template<class T>
T power(T a, i64 b) {
    T res = 1;
    for (; b; b /= 2, a *= a) {
        if (b % 2) {
            res *= a;
        }
    }
    return res;
}
struct Z {
    int x;
    Z(int x = 0) : x(norm(x)) {}
    Z(i64 x) : x(norm(x % P)) {}
    int val() const {
        return x;
    }
    Z operator-() const {
        return Z(norm(P - x));
    }
    Z inv() const {
        assert(x != 0);
        return power(*this, P - 2);
    }
    Z &operator*=(const Z &rhs) {
        x = i64(x) * rhs.x % P;
        return *this;
    }
    Z &operator+=(const Z &rhs) {
        x = norm(x + rhs.x);
        return *this;
    }
    Z &operator-=(const Z &rhs) {
        x = norm(x - rhs.x);
        return *this;
    }
    Z &operator/=(const Z &rhs) {
        return *this *= rhs.inv();
    }
    friend Z operator*(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res *= rhs;
        return res;
    }
    friend Z operator+(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res += rhs;
        return res;
    }
    friend Z operator-(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res -= rhs;
        return res;
    }
    friend Z operator/(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res /= rhs;
        return res;
    }
    friend std::istream &operator>>(std::istream &is, Z &a) {
        i64 v;
        is >> v;
        a = Z(v);
        return is;
    }
    friend std::ostream &operator<<(std::ostream &os, const Z &a) {
        return os << a.val();
    }
};

void debug(){
    #if DEBUG
    freopen("test1.txt", "r", stdin);
    #else
    fastio;
    #endif
}

Z dp[256][256][256];//n, 最大值, 最大值个数
Z inv[256];
Z p[256][256], sumt[256][256];

void solve(){
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; ++i){
        inv[i] = Z(i).inv();
    }
    for(int m = 1; m <= k; ++m){
        Z tmp = Z(1);
        Z zm = Z(m);
        p[m][0] = tmp;
        dp[1][m][1] = 1;
        sumt[1][m] = m;
        for(int i = 1; i <= n; ++i){
            tmp *= zm;
            p[m][i] = tmp;
        }
    }

    Z sumres = 0;
    for(int i = 2; i <= n-1; ++i){
        sumres = 0;
        for(int j = 1; j <= k; ++j){
            sumt[i][j] = sumt[i][j-1];
            if(j != 1){
                dp[i][j][1] = sumt[i-1][j-1]*Z(i)*p[k-j+1][i-1];
                //printf("dp[%d][%d][1]==%d, sumt[%d][%d]==%d\n", i, j, dp[i][j][1], i-1, j-1, sumt[i-1][j-1]);
                sumt[i][j] += dp[i][j][1];
                sumres += dp[i][j][1];
            }
            for(int t = 2; t <= i; ++t){
                if(j == 1 && t != i) continue;
                dp[i][j][t] = dp[i-1][j][t-1]*Z(i)*inv[t]*p[k-j+1][i-1];
                //printf("dp[%d][%d][%d(>1)]==%d\n", i, j, t, dp[i][j][t]);
                sumt[i][j] += dp[i][j][t];
                sumres += dp[i][j][t];
            }//t
        }//j
    }//i

    cout << sumres << "\n";
}

signed main(void){
    debug();
    int t;
    #if SINGLE
    t = 1;
    #else
    cin >> t;
    #endif
    while(t--) solve();
}


#include <locale.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iterator>
#include <sstream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <random>
#include <ctime>
#include <queue>
#include <set>
using namespace std;
using ld = long double;
using ll = long long;

ll mod = 998244353;
int const N = 3e5 + 100;

mt19937 rnd;

ll  random(ll  limit)
{
	uniform_int_distribution <ll > uniform_dist(0, limit);
	return uniform_dist(rnd);
}

ll bpow(ll a, ll p) {
	ll res = 1;
	while (p > 0) {
		if (p % 2) {
			res = res * a % mod;
		}
		a = a * a % mod;
		p /= 2;
	}
	return res;
}

ll inv(ll a) {
	return bpow(a, mod - 2);
}

void solve() {
	ll n, k;
	cin >> n >> k;
	n--;
	vector<vector<ll>> dp(n + 1, vector<ll>(k));
	/*for (int i = 0; i < k; i++) {
		dp[0][i] = 1;
	}*/
	dp[0][0] = 1;

	vector<vector<ll>> binom(1000, vector<ll>(1000 + 1));

	binom[0][0] = 1;
	for (ll i = 1; i < 100; i++) {
		for (ll j = 0; j <= i; j++) {
			if (j > 0) {
				binom[i][j] += binom[i - 1][j - 1];
				binom[i][j] %= mod;
			}
			binom[i][j] += binom[i - 1][j];
			binom[i][j] %= mod;
		}
	}

	vector<vector<ll>> psum(n + 1, vector<ll>(k));
	for (int i = 0; i < k; i++)
		psum[0][i] = 1;

	for (int i = 1; i <= n; i++) {
		dp[i][0] = bpow(k, i * (i - 1) / 2) % mod;
		psum[i][0] = dp[i][0];

		for (int j = 1; j < k; j++) {
			for (int num = 1; num <= i; num++) {

				dp[i][j] += ((binom[i][num] * psum[i - num][j - 1]) % mod) * bpow(k - j, num * (2 * i - num - 1) / 2) % mod;
				dp[i][j] %= mod;
			}
			psum[i][j] = psum[i][j-1] + dp[i][j];
			psum[i][j] %= mod;

		}

	}

	cout << psum[n][k - 1] % mod << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	rnd = mt19937(956231);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
	}

}

/*

*/


#define _CRT_SECURE_NO_WARNINGS

#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <tuple>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <cassert>

using namespace std;

template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint() :v(0) {}
	mint(__int64 _v) {
		v = int((-MOD < _v&& _v < MOD) ? _v : _v % MOD);
		if (v < 0) v += MOD;
	}
	bool operator==(const mint& o) const {
		return v == o.v;
	}
	friend bool operator!=(const mint& a, const mint& b) {
		return !(a == b);
	}
	friend bool operator<(const mint& a, const mint& b) {
		return a.v < b.v;
	}
	// friend void re(mint& a) { __int64 x; re(x); a = mint(x); }
	// friend str ts(mint a) { return ts(a.v); }

	mint& operator+=(const mint& o) {
		if ((v += o.v) >= MOD) v -= MOD;
		return *this;
	}
	mint& operator-=(const mint& o) {
		if ((v -= o.v) < 0) v += MOD;
		return *this;
	}
	mint& operator*=(const mint& o) {
		v = int((__int64)v * o.v % MOD); return *this;
	}
	mint& operator/=(const mint& o) { return (*this) *= inv(o); }
	friend mint pow(mint a, __int64 p) {
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	friend mint inv(const mint& a) {
		assert(a.v != 0);
		return pow(a, MOD - 2);
	}

	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};
#define MOD 998244353
typedef mint<MOD, 5> mint1;
int n, k;
void init(){
	cin >> n >> k;
}
void calccnk(vector<vector<mint1>> &cnk, int n) {
	cnk[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		cnk[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			cnk[i][j] = cnk[i - 1][j - 1];
			if (j < i)
				cnk[i][j] += cnk[i - 1][j];
		}
	}
}
void solve(){
	auto f = vector<vector<mint1>>(n + 1, vector<mint1>(k + 1));
	vector<vector<mint1>> cnk = vector<vector<mint1>>(n + 1, vector<mint1>(n + 1));
	calccnk(cnk, n);
	for (int i = 0; i <= k; i++) {
		f[0][i] = 1;
	}
	f[1][0] = 0;
	for (int i = 1; i <= n; i++) {
		f[i][0] = 0;
		f[i][1] = pow(k, i * (i - 1) / 2);
		for (int p = 2; p <= k; p++) {
			f[i][p] = f[i][p - 1];
			for (int j = 1; j <= i; j++) {
				//c(i,j) * pow(k - p + 1, j * (j - 1) / 2) * f(i - j, p - 1) * pow(k - p + 1, j * (i - j))
				mint1 tmp;
				tmp = cnk[i][j] * pow(mint1(k - p + 1), j * (j - 1) / 2 + j * (i - j)) * f[i - j][p - 1];
				f[i][p] += tmp;
			}
		}
	}

	cout << (int)f[n - 1][k] << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	init();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
namespace Legendgod {
	namespace Read {
//		#define Fread
		#ifdef Fread
		const int Siz = (1 << 21) + 5;
		char *iS, *iT, buf[Siz];
		#define gc() ( iS == iT ? (iT = (iS = buf) + fread(buf, 1, Siz, stdin), iS == iT ? EOF : *iS ++) : *iS ++ )
		#define getchar gc
		#endif
		template <typename T>
		void r1(T &x) {
		    x = 0;
			char c(getchar());
			int f(1);
			for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
			for(; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
			x *= f;
		}
		template <typename T, typename...Args>
		void r1(T &x, Args&...arg) {
			r1(x), r1(arg...);
		}
		#undef getchar
	}

using namespace Read;

const int maxn = 200 + 5;

int n, mod;
int fac[maxn], finv[maxn];
int ksm(int x,int mi) {
    int res(1);
    while(mi) {
        if(mi & 1) res = 1ll * res * x % mod;
        mi >>= 1;
        x = 1ll * x * x % mod;
    }
    return res;
}

void init(int x) {
    fac[0] = 1;
    for(int i = 1; i <= x; ++ i) fac[i] = 1ll * fac[i - 1] * i % mod;
    finv[x] = ksm(fac[x], mod - 2);
    for(int i = x - 1; i >= 0; -- i) finv[i] = 1ll * finv[i + 1] * (i + 1) % mod;
}

int vis[maxn][maxn][50], f[maxn][maxn][50];
int a1;

int dfs(int dep,int sum,int K,int lim) {
    if(vis[dep][sum][K]) return f[dep][sum][K];
    vis[dep][sum][K] = 1;
    int& ret = f[dep][sum][K]; ret = 0;
    if(K < lim && dep < K) return 0;
    if(K == lim) {
        if(dep < n) ret = finv[n - dep];
        return ret;
    }
    int nx = n + 1 - K - a1;
    for(int j = 0; dep + j <= n && j * nx + sum <= a1; ++ j)
        ret = (ret + 1ll * dfs(dep + j, j * nx + sum, K + 1, lim) * finv[j] % mod) % mod;
    return ret;
}

signed main() {
	int i, j;
    r1(n, mod);
    init(n + 5);
    int ans(0);
    for(int lim = 0; lim <= n; ++ lim) {
        memset(vis, 0, sizeof(vis));
        a1 = n + 1 - lim;
        int x = dfs(0, 0, 0, lim);
        if(x == 0) break;
        ans = (ans + x) % mod;
    }
    ans = 1ll * ans * fac[n] % mod;
    printf("%d\n", ans);
	return 0;
}

}

signed main() { return Legendgod::main(), 0; }


#include<bits/stdc++.h>
#include<cstdio>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define RI re int
#define ll long long
#define db double
#define lb long db
#define N (200+5)
#define M (N*50+5)
#define mod 998244353
#define Mod (mod-1)
#define eps (1e-9)
#define U unsigned int
#define it iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) (n*(x-1)+(y))
#define R(n) (rand()*rand()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define PB push_back
using namespace std;
int n,m,k,p,A[N+5],Cnt,P,Ne,La,vis[22][N][N];ll dp[22][N][N],frc[N],Inv[N],Ans;
I ll mpow(ll x,int y=p-2){ll Ans=1;while(y) y&1&&(Ans=Ans*x%p),y>>=1,x=x*x%p;return Ans;}
I ll dfs(int x,int S,int w){
	if(vis[x][S][w]) return dp[x][S][w];ll &Ns=dp[x][S][w];vis[x][S][w]=1;Ns=0;
	if(x<m&&x>w)return 0;if(x==m){if(w^n) Ns=Inv[n-w];return Ns;}
	for(RI i=0;i+w<=n&&S+i*(m-x)<=n-m+1;i++) Ns=(Ns+dfs(x+1,S+i*(m-x),w+i)*Inv[i])%p;return Ns;
}
int main(){
	//freopen("1.in","r",stdin);
	RI i;scanf("%d%d",&n,&p);for(frc[0]=Inv[0]=i=1;i<=n;i++) frc[i]=frc[i-1]*i%p,Inv[i]=mpow(frc[i]);
	for(i=max(n-20,2);i<=n+1;i++)Me(vis,0),m=n-i+1,Ans+=dfs(0,0,0);printf("%lld\n",Ans%p*frc[n]%p);
}


#include <cstdio>
const int Maxn=200;
int n,Mod;
int f[Maxn+5][Maxn+5][Maxn+5];
int inv_f[Maxn+5],fac[Maxn+5],inv[Maxn+5];
int main(){
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	scanf("%d%d",&n,&Mod);
	inv[1]=1;
	for(int i=2;i<=n;i++){
		inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	}
	fac[0]=inv_f[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%Mod;
		inv_f[i]=1ll*inv_f[i-1]*inv[i]%Mod;
	}
	for(int i=1;i<n;i++){
		f[n+1][i][0]=inv_f[i];
	}
	int ans=2;
	for(int i=n;i>0;i--){
		for(int j=1;j<n;j++){
			for(int k=0;k+j<=i;k++){
				if(n-j<=i){
					ans=(ans+1ll*f[i+1][j][k]*inv_f[n-j]%Mod*fac[n])%Mod;
				}
			}
		}
		for(int j=n-i+1;j<n;j++){
			for(int k=n-i;j+k<=i;k++){
				f[i][j][j+k]=(f[i][j][j+k]+f[i+1][j][k])%Mod;
			}
		}
		for(int j=n-1;j>n-i;j--){
			for(int l=1;j+l<n;l++){
				for(int k=n+1-i;k<=i;k++){
					f[i][j+l][k]=(f[i][j+l][k]+1ll*f[i][j][k]*inv_f[l])%Mod;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}
//


#include<bits/stdc++.h>
using namespace std;
const int N=220;
int n,mod,ans;
int ksm(int a,int x){
    int tot=1;
    while(x){
        if(x & 1ll) tot=1ll*tot*a%mod;
        a=1ll*a*a%mod;
        x>>=1ll;
    }
    return tot;
}
int mul[N],inv[N];
void init(int lim){
    mul[0]=inv[0]=1;
    for(int i=1;i<=lim;i++) mul[i]=1ll*mul[i-1]*i%mod;
    inv[lim]=ksm(mul[lim],mod-2);
    for(int i=lim-1;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int m,int n){
    if(m<0 || m<n) return 0;
    return 1ll*mul[m]*inv[n]%mod*inv[m-n]%mod;
}

int f[N][N][N];
int main(){
    cin>>n>>mod;
    init(N-5);
    int lim=n-sqrt(n);
    for(int b1=lim;b1<=n;b1++){
        // cout<<endl<<endl<<b1<<":  "<<endl;
        memset(f,0,sizeof(f));
        for(int i=1;i<=n;i++) f[i][0][0]=inv[i];
        for(int i=1;i<=n;i++){
            // cout<<i<<": "<<endl;
            for(int j=max(1,i+1-b1);j<=min(b1,n+1-b1);j++){
                for(int sum=0;sum<=b1;sum++){
                    for(int p=0;p<=min(i,sum/j);p++)
                        f[i][j][sum]=(f[i][j][sum]+1ll*f[i-p][j-1][sum-j*p]*inv[p]%mod)%mod;
                    // cout<<f[i][j][sum]<<" ";
                }
                // cout<<endl;
            }
        }
        int tot=0;
        for(int sum=0;sum<=b1;sum++) tot=(tot+f[n][n+1-b1][sum])%mod;
        ans=(ans+1ll*tot*mul[n]%mod)%mod;
    }
    cout<<(ans+1)%mod;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=205;
int n,mod,frst,fac[N],inv[N],dp[N][N][50];
bool vis[N][N][50];
int Pow(int a,int b){
	int rec=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)rec=1ll*rec*a%mod;
	return rec;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=Pow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int dfs(int cnt,int sum,int cur,int lim){
	if(vis[cnt][sum][cur])return dp[cnt][sum][cur];
	vis[cnt][sum][cur]=true;
	int &rec=dp[cnt][sum][cur];rec=0;
	if(cur<=lim-1&&cnt<cur)return rec;
	if(cur==lim){
		if(cnt<n)rec=inv[n-cnt];
		return rec;
	}
	int x=n+1-cur-frst;
	for(int j=0;cnt+j<=n&&sum+j*x<=frst;j++)
		rec=(rec+1ll*dfs(cnt+j,sum+j*x,cur+1,lim)*inv[j]%mod);
	return rec;
}
int main(){
    scanf("%d%d",&n,&mod);init(n);
    int ans=0;
    for(int lim=0;lim<=32;lim++){
    	memset(vis,0,sizeof vis);
    	frst=n+1-lim;
    	ans=(ans+dfs(0,0,0,lim))%mod;
    }
    printf("%lld\n",1ll*ans*fac[n]%mod);
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define dwn(i,x,y) for(int i=x;i>=y;i--)
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
template<typename T>inline void qr(T &x){
  x=0;int f=0;char s=gc();
  while(s<'0'||'9'<s)f|=s=='-',s=gc();
  while('0'<=s&&s<='9')x=x*10+s-48,s=gc();
  x=f?-x:x;
}
int cc=0,buf[31];
template<typename T>inline void qw(T x){
  if(x<0)putchar('-'),x=-x;
  do{buf[++cc]=int(x%10);x/=10;}while(x);
  while(cc)pc(buf[cc--]+'0');pc(' ');
}
const int N=210;
int n,mod,frst;
int fc[N],ifc[N],dp[N][N][50];
bool v[N][N][50];
int power(int a,int b){
  int ret=1;
  while(b){
    if(b&1)ret=1ll*ret*a%mod;
    a=1ll*a*a%mod;b>>=1;
  }
  return ret;
}
int dfs(int cnt,int sum,int cur,int lim){
  if(v[cnt][sum][cur])return dp[cnt][sum][cur];
  v[cnt][sum][cur]=1;
  int &ret=dp[cnt][sum][cur];ret=0;
  if(cur<=lim-1&&ret<cur)return ret;
  if(cur==lim){
    if(cnt<n)ret=ifc[n-cnt];
    return ret;
  }
  int x=n+1-cur-frst;
  for(int j=0;cnt+j<=n&&sum+j*x<=frst;j++)
    ret=(ret+1ll*dfs(cnt+j,sum+j*x,cur+1,lim)*ifc[j]%mod)%mod;
  return ret;
}
int main(){
  qr(n),qr(mod);
  fc[0]=1;
  rep(i,1,n)fc[i]=1ll*fc[i-1]*i%mod;
  ifc[n]=power(fc[n],mod-2);
  dwn(i,n-1,0)ifc[i]=1ll*ifc[i+1]*(i+1)%mod;
  int ans=0;
  rep(lim,0,32){
    mst(v,0);
    frst=n+1-lim;
    ans=(ans+dfs(0,0,0,lim))%mod;
  }
  qw(1ll*ans*fc[n]%mod);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,T,p[N],pcnt,f[N];
ll phi[N],dp[20][N];
inline void init(int n){
	phi[1]=1;
	for(int i=2;i<=n;++i){
		if(!f[i]) p[++pcnt]=i,phi[i]=i-1;
		for(int j=1;j<=pcnt&&i*p[j]<=n;++j){
			int num=i*p[j];f[num]=1;
			if(i%p[j]) phi[num]=phi[i]*phi[p[j]];
			else{
				phi[num]=phi[i]*p[j];
				break;
			}
		}
	}
	for(int i=2;i<=n;++i) phi[i]+=phi[i-1];
}
inline ll calc(int l,int r){
	ll ret=0;
	for(int x=l,y=0;x<=r;x=y+1){
		y=r/(r/x);
		ret+=phi[r/x]*(y-x+1);
	}
	return ret;
}
inline void solve(int x,int l,int r,int ql,int qr){
	if(l>r) return ;
	int mid=(l+r)>>1,pos=ql;ll now=calc(min(qr+1,mid),mid);
	dp[x][mid]=1e15;
	for(int i=min(qr,mid-1);i>=ql;--i){
		if(dp[x-1][i]+now<dp[x][mid]) dp[x][mid]=dp[x-1][i]+now,pos=i;
		now+=phi[mid/i];
	}
	solve(x,l,mid-1,ql,pos);solve(x,mid+1,r,pos,qr);
}
int main(){
	n=100000;
	init(n);
	for(int i=1;i<=n;++i) dp[1][i]=1ll*i*(i+1)/2;
	for(int i=2;(1<<i)<=n;++i) solve(i,i,n,1,n);
	scanf("%d",&T);
	while(T--){
		int k;
		scanf("%d%d",&n,&k);
		if(k>=20||(1<<k)>n){printf("%d\n",n);continue;}
		else printf("%lld\n",dp[k][n]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(var) var.begin(),var.end()
const int N = 207;
const int SUM = N*N;
int MOD;
int binpow(ll x,int power){
    ll mult = x%MOD;
    x = 1;
    while(power){
        if (power&1)
            x = x*mult%MOD;
        mult = mult*mult%MOD;
        power = power>>1;
    }
    return x;
}
ll fact[N],rev[N];
int C(int n,int k){
    return fact[n]*rev[k]%MOD*rev[n-k]%MOD;
}
int dp[20][SUM][N],mv[N];
int last;
int n;
int F(int cur,int sum,int cnt,int mi){
    if (cur*mi<sum || sum>cur*cnt || sum<mi*cnt)
        return 0;
    if (dp[cur-mi][sum][cnt]!=-1)
        return dp[cur-mi][sum][cnt];

    if (cur==mi){
        if (sum!=mi*cnt || cnt>mi || cnt==0)
            dp[cur-mi][sum][cnt] = 0;
        else
            dp[cur-mi][sum][cnt] = 1;
        return dp[cur-mi][sum][cnt];
    }
    dp[cur-mi][sum][cnt] = F(cur-1,sum,cnt,mi);
    int sa = 0;
    for(int add = 1;add<=cnt && sa<=sum;++add){
        sa+=cur;
        ll ret = F(cur-1,sum-sa,cnt-add,mi);
        if (ret==0)
            continue;
        ret = ret*C(cnt,add);
        if (ret>MOD*2)
            ret%=MOD;
        if (ret>=MOD)
            ret-=MOD;
        dp[cur-mi][sum][cnt]+=ret;
        if (dp[cur-mi][sum][cnt]>=MOD)
            dp[cur-mi][sum][cnt]-=MOD;
    }
    return dp[cur-mi][sum][cnt];
}
void solve(){

    cin>>n>>MOD;
    fact[0] = 1;
    for(int i = 1;i<N;++i){
        fact[i] = fact[i-1]*i%MOD;
    }
    rev[N-1] = binpow(fact[N-1],MOD-2);
    for(int i = N-2;i>=0;--i){
       rev[i] = rev[i+1]*(i+1)%MOD;
    }

    for(int i = n+1;i>=1;--i){
        int sum = 0,cnt = 0;
        for(int j = i;j<=n+1;++j){
           while(i*j>=sum+j)
               sum+=j,mv[++cnt] = j;
        }
        if (cnt<n){
            last = i+1;
            break;
        }
    }

    ll res = 0;
    for(int mi = last;mi<=n+1;++mi) {
        memset(dp,-1,sizeof(dp));
        for (int w = 0; w <= (n + 1) * (n + 1); ++w)
            res += F(n + 1, w, n,mi);
    }
    cout<<res%MOD<<endl;
}

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;

    while(t--)
        solve();

}


//Only inp[1]*inp[i]>=inp[1]+...+inp[n] matters
#include<bits/stdc++.h>
using namespace std;

const int nmax=2e2+5;

long long OUTP=0;

int n,m;

int inp[nmax];

int c[nmax][nmax];

int states=0;

vector< pair< pair<int/*sum*/,int/*position*/>,int/*value*/> > dp[nmax],help;

void extend(int sum,int prv,int pos,long long coeff)
{
    if(pos==n)
    {
        OUTP=(OUTP+coeff)%m;
        return;
    }

    if(prv==n+1)return;

    if(inp[1]*(n+1)<sum+(n-pos)*(prv+1))return;

    states++;

    dp[prv+1].push_back({{sum,pos},coeff});

    int new_val=prv+1;

    int sum_new=sum;

    for(int pos_now=1;pos_now+pos<=n;pos_now++)
    {
        sum_new+=new_val;

        if(sum_new>inp[1]*new_val)break;

        //long long cur=rec(sum_new,new_val,pos+pos_now)*c[n-pos][pos_now];
        dp[new_val].push_back({{sum_new,pos+pos_now},coeff*c[n-pos][pos_now]%m});
    }
}

int main()
{
    scanf("%i%i",&n,&m);

    if(n==1)
    {
        printf("%i\n",1%m);
        return 0;
    }

    for(int i=0;i<nmax;i++)
        for(int j=0;j<=i;j++)
            if(j==0||j==i)c[i][j]=1;
            else c[i][j]=(c[i-1][j]+c[i-1][j-1])%m;

    //P(1,j) => j<=inp[j]
    int low=1;

    while(1)//Repeatedly apply inp[i]>=max(c,i) and P(1,n): inp[1]*inp[n]>=c+c+...+c+(c+1)+...+(n-1)+inp[n] and inp[n]<=n+1
    {
        int up=2*(n+1+low*low)+(n+low)*(n-1-low);

        int down=2*(n+1);

        int low_new=(up+down-1)/down;

        if(low<low_new)low=low_new;
        else break;
    }

    for(inp[1]=low;inp[1]<=n+1;inp[1]++)
    {
        for(int j=1;j<=n+1;j++)dp[j]={};

        for(int t=1;t<=inp[1]&&t<=n;t++)
        {
            dp[inp[1]].push_back({{inp[1]*t,t},c[n][t]});
        }

        for(int prv=inp[1];prv<=n+1;prv++)
        {
            sort(dp[prv].begin(),dp[prv].end());

            help={};
            for(auto w:dp[prv])
                if(help.size()&&help.back().first==w.first)help.back().second=(help.back().second+w.second)%m;
                else help.push_back(w);

            dp[prv]={};
            dp[prv].shrink_to_fit();

            for(auto w:help)
                extend(w.first.first,prv,w.first.second,w.second);
        }
    }

    printf("%i\n",OUTP);

    return 0;
}


//
//  main.cpp
//  1603E
//
//  Created by BuffaloHome on 11/6/21.
//

#include <iostream>
using namespace std;

/**
 Analysis of problem:
 array is perfect if after sorted:
 for any index i:
 a0 * ai >= a0 + ... + ai
 or equiv:
 (a0-1) * ai >= a0 + ... + a[i-1]

 Consider a0 fixed.
 Denote f[i, s] to be:
 number of perfect sequence with length i, sum = s,  maximum is m.

 f[i, s, m] =sum_o f[i - o, s - 0*m, m-1] *  C()
 TLE, optimize?

 New idea:
 condition is equivalent to:
 at any point in sequence:
 Delta <= a1(ak - k + 1) - ak
 ak >= k

 Equivalent:
 1. b1 + ... + bn <= a1
 2. k-th maximum >= n + 2 - k, or if k-th maximum = n+ 1 - k, all value below this equal n + 1 - k.

 Recursive:
 f (len, sum, max)
 // max is allowed max

 if allowed max is tight: a1 + max = len:
    check a1 = len, max = 0,

 allowed max not tight:
 Consider the occurences of max.
 f = \sum_o f(len - occ, sum - occ * delta, max - 1)

 */

int N = 200;
int n, M;
long long dp[201][201][201];
long long fac[201];
long long inv[201];

long long power(long long k, int p, int M) {
    if (p == 0) {
        return 1;
    }
    long long y = power (k, p/2, M);
    long long z = y * y % M;
    if (p % 2 == 0) {
        return z;
    }
    else {
        return z * k % M;
    }
}

void computeMod(int M) {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) {
        fac[i] = fac[i-1] * i % M;
        //cout << fac[i] << " ";
    }
    //cout << endl;

    inv[N] = power(fac[N], M-2, M);
    for (int i = N - 1; i >= 0; --i) {
        inv[i] = inv[i+1] * (i+1) % M;
        //cout << inv[i] << " ";
    }
    //cout << endl;
}

long long f(int len, int max, int sum, int a1) {

    /**
     Computes # seq of len such that
     b1 + ... + bn <= sum
     bn <= max
     [a1 + bk >= k + 1
     or a1 + bk = k and a1 = k, b1= ... = bk = 0]
     */

    if (dp[len][max][sum] != -1) {
        return dp[len][max][sum];
    }

    if (max == 0 && len > 0) {
        dp[len][max][sum] = inv[len];

        //  50 100757149
        //cout << "base: len, max, sum " << len << " " << max << " " << sum << " = " << dp[len][max][sum]  % M << endl;

        return inv[len];
    }

    if (a1 + max >= len + 1) {
        long long g = 0;
        for (int occ = 0; occ <= len && occ * max <= sum ; occ ++) {
            long long val = f(len - occ, max - 1, sum - occ * max, a1);
            //cout << occ << " " << val * inv[occ] << endl;
            g = (g + val * inv[occ]) % M;
        }
        dp[len][max][sum] = g;
        //cout << "len, max, sum " << len << " " << max << " " << sum << " = " << dp[len][max][sum]  % M << endl;
        return g;
    }

    return 0;
}

void solve(int n, int M) {
    // Find # perfect array of len n, elements 1 <= ai <= n+1
    if (n == 1) {
        cout << 2 % M;
        return;
    }

    memset(dp, -1, sizeof(dp));

    computeMod(M);

    long long ans = 0;
    for (int a1 = n + 1; a1 >= 1 && a1 >= n - 20; --a1) {
        memset(dp, -1, sizeof(dp));
        long long val = f(n, n + 1 - a1, a1, a1);
        ans = ans + val % M;
        // cout << f(n, n+1, a1, a1)  * fac[n] % M << " " << endl;;
    }

    ans = ans * fac[n] % M;
    cout << ans << endl;

    return;
}

int main() {
    // insert code here...

    cin >> n >> M;

    solve (n, M);

    /**

    n = 3;
    for (int i = 1; i <= n+1; ++i) {
        for (int j = i; j <= n+1; ++j) {
            for (int k = j; k <= n+1; ++k) {
                if (i * j >= i + j && i * k >= i + j + k) {
                    cout << i << ' ' << j << " " << k << endl;
                }
            }
        }
    }

    n = 4;
    int cnt = 0;
    for (int i = 1; i <= n+1; ++i) {
        for (int j = i; j <= n+1; ++j) {
            for (int k = j; k <= n+1; ++k) {
                for (int l = k; l <= n+1; ++l)
                    if (i * j >= i + j && i * k >= i + j + k && i * l >= i + j + k + l) {
                        cout << i << ' ' << j << " " << k << " " << l <<endl;
                        cnt ++;
                }
            }
        }
    }
    cout << cnt;
     */

    return 0;
}


//
//  main.cpp
//  1603E
//
//  Created by BuffaloHome on 11/6/21.
//

#include <iostream>
#include <string.h>
using namespace std;

/**
 Analysis of problem:
 array is perfect if after sorted:
 for any index i:
 a0 * ai >= a0 + ... + ai
 or equiv:
 (a0-1) * ai >= a0 + ... + a[i-1]

 Consider a0 fixed.
 Denote f[i, s] to be:
 number of perfect sequence with length i, sum = s,  maximum is m.

 f[i, s, m] =sum_o f[i - o, s - 0*m, m-1] *  C()
 TLE, optimize?

 New idea:
 condition is equivalent to:
 at any point in sequence:
 Delta <= a1(ak - k + 1) - ak
 ak >= k

 Equivalent:
 1. b1 + ... + bn <= a1
 2. k-th maximum >= n + 2 - k, or if k-th maximum = n+ 1 - k, all value below this equal n + 1 - k.

 Recursive:
 f (len, sum, max)
 // max is allowed max

 if allowed max is tight: a1 + max = len:
    check a1 = len, max = 0,

 allowed max not tight:
 Consider the occurences of max.
 f = \sum_o f(len - occ, sum - occ * delta, max - 1)

 */

int N = 200;
int n, M;
long long dp[201][201][201];
long long fac[201];
long long inv[201];

long long power(long long k, int p, int M) {
    if (p == 0) {
        return 1;
    }
    long long y = power (k, p/2, M);
    long long z = y * y % M;
    if (p % 2 == 0) {
        return z;
    }
    else {
        return z * k % M;
    }
}

void computeMod(int M) {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) {
        fac[i] = fac[i-1] * i % M;
        //cout << fac[i] << " ";
    }
    //cout << endl;

    inv[N] = power(fac[N], M-2, M);
    for (int i = N - 1; i >= 0; --i) {
        inv[i] = inv[i+1] * (i+1) % M;
        //cout << inv[i] << " ";
    }
    //cout << endl;
}

long long f(int len, int max, int sum, int a1) {

    /**
     Computes # seq of len such that
     b1 + ... + bn <= sum
     bn <= max
     [a1 + bk >= k + 1
     or a1 + bk = k and a1 = k, b1= ... = bk = 0]
     */

    if (dp[len][max][sum] != -1) {
        return dp[len][max][sum];
    }

    if (max == 0 && len > 0) {
        dp[len][max][sum] = inv[len];

        //  50 100757149
        //cout << "base: len, max, sum " << len << " " << max << " " << sum << " = " << dp[len][max][sum]  % M << endl;

        return inv[len];
    }

    if (a1 + max >= len + 1) {
        long long g = 0;
        for (int occ = 0; occ <= len && occ * max <= sum ; occ ++) {
            long long val = f(len - occ, max - 1, sum - occ * max, a1);
            //cout << occ << " " << val * inv[occ] << endl;
            g = (g + val * inv[occ]) % M;
        }
        dp[len][max][sum] = g;
        //cout << "len, max, sum " << len << " " << max << " " << sum << " = " << dp[len][max][sum]  % M << endl;
        return g;
    }

    return 0;
}

void solve(int n, int M) {
    // Find # perfect array of len n, elements 1 <= ai <= n+1
    if (n == 1) {
        cout << 2 % M;
        return;
    }

    memset(dp, -1, sizeof(dp));

    computeMod(M);

    long long ans = 0;
    for (int a1 = n + 1; a1 >= 1 && a1 >= n - 20; --a1) {
        memset(dp, -1, sizeof(dp));
        long long val = f(n, n + 1 - a1, a1, a1);
        ans = ans + val % M;
        // cout << f(n, n+1, a1, a1)  * fac[n] % M << " " << endl;;
    }

    ans = ans * fac[n] % M;
    cout << ans << endl;

    return;
}

int main() {
    // insert code here...

    cin >> n >> M;

    solve (n, M);

    /**

    n = 3;
    for (int i = 1; i <= n+1; ++i) {
        for (int j = i; j <= n+1; ++j) {
            for (int k = j; k <= n+1; ++k) {
                if (i * j >= i + j && i * k >= i + j + k) {
                    cout << i << ' ' << j << " " << k << endl;
                }
            }
        }
    }

    n = 4;
    int cnt = 0;
    for (int i = 1; i <= n+1; ++i) {
        for (int j = i; j <= n+1; ++j) {
            for (int k = j; k <= n+1; ++k) {
                for (int l = k; l <= n+1; ++l)
                    if (i * j >= i + j && i * k >= i + j + k && i * l >= i + j + k + l) {
                        cout << i << ' ' << j << " " << k << " " << l <<endl;
                        cnt ++;
                }
            }
        }
    }
    cout << cnt;
     */

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif

#define gcd(a, b) __gcd(a, b)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rsort(x) sort(x, [](auto a, auto b) { rtn a > b; });
#define forr(i, v) for (int i = 0; i < v; i++)
#define each(x, v) for (auto x : v)
#define forrr(i, j, v, w)       \
    for (int i = 0; i < v; i++) \
        for (int j = 0; j < w; j++)
#define ni(x) \
    int x;    \
    cin >> x;
#define nii(x, y) \
    int x, y;     \
    cin >> x >> y;
#define niii(x, y, z) \
    int x, y, z;      \
    cin >> x >> y >> z;
#define niiii(w, x, y, z) \
    int w, x, y, z;       \
    cin >> w >> x >> y >> z;
#define nl(x) \
    ll x;     \
    cin >> x;
#define nll(x, y) \
    ll x, y;      \
    cin >> x >> y;
#define nlll(x, y, z) \
    ll x, y, z;       \
    cin >> x >> y >> z;
#define nllll(w, x, y, z) \
    ll w, x, y, z;        \
    cin >> w >> x >> y >> z;
#define get(v)   \
    vi v;        \
    forr(i, n)   \
    {            \
        ni(x);   \
        v.pb(x); \
    }
#define amax(a, b) a = max(a, b);
#define amin(a, b) a = min(a, b);
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rz resize
#define sz size()
#define cnt continue
#define brk break
#define rtn return
#define W()   \
    int T;    \
    cin >> T; \
    while (T--)
#define trace(x) cerr << #x << ": " << x << endl;
#define output()
#define ff first
#define float double
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<str> vs;
typedef vector<pii> vpii;
typedef vector<pdd> vpdd;
typedef vector<vpii> vppii;
typedef vector<vi> vii;
typedef vector<vb> vbb;
typedef vector<vl> vll;
typedef unordered_map<int, int> mpii;
typedef set<int> seti;
typedef set<ll> setl;
typedef set<pair<int, int>> spii;
typedef vector<set<int>> vseti;

const ll linf = 1e18 + 10;
const int inf = 1e9 + 10;
const double eps = 1e-9;
const double pi = 3.1415926535897932384626433832795;
int mod = 1000000007;
const int base = 31;

ll max(ll a, ll b)
{
    return a > b ? a : b;
}

ll min(ll a, ll b)
{
    return a < b ? a : b;
}

int count1(int x)
{
    rtn __builtin_popcount(x);
}

int count1(ll x)
{
    rtn __builtin_popcountll(x);
}

void out(vl v)
{
    for (ll i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vi v)
{
    for (int i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(seti v)
{
    for (int i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(setl v)
{
    for (ll i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vd v)
{
    for (double i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vb v)
{
    for (bool i : v)
    {
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vii v)
{
    for (vi i : v)
    {
        out(i);
    }
    cerr << endl;
}

void out(vbb v)
{
    for (vb i : v)
    {
        out(i);
    }
    cerr << endl;
}

void out(vll v)
{
    for (vl i : v)
    {
        out(i);
    }
    cerr << endl;
}

void out(pii i)
{
    cerr << "<" << i.ff << "," << i.ss << ">  ";
}

void out(pdd i)
{
    cerr << "<" << i.ff << "," << i.ss << ">  ";
}

void out(vpii v)
{
    for (pii i : v)
    {
        out(i);
    }
    cerr << endl;
}

void out(mpii v)
{
    for (pii i : v)
    {
        cerr << "<" << i.ff << "=>" << i.ss << ">  ";
    }
    cerr << endl;
}

void out(int v[], int n)
{
    forr(i, n)
    {
        cerr << v[i] << " ";
    }
    cerr << endl;
}

void out(map<int, int> v)
{
    for (pii i : v)
    {
        cerr << "<" << i.ff << "->" << i.ss << ">  ";
    }
    cerr << endl;
}

int add(int a, int b)
{
    int res = (a + b) % mod;
    if (res < 0)
        res += mod;
    rtn res;
}

void iadd(int &a, int b)
{
    a = add(a, b);
}

int mul(int a, int b)
{
    int res = (a * 1LL * b) % mod;
    if (res < 0)
        res += mod;
    rtn res;
}

void imul(int &a, int b)
{
    a = mul(a, b);
}

int power(int a, int b)
{
    int res = 1;
    while (b)
    {
        if (b % 2)
            res = mul(res, a);
        a = mul(a, a);
        b /= 2;
    }
    rtn res;
}

void ipower(int &a, int b)
{
    a = power(a, b);
}

int inv(int x)
{
    rtn x == 1 ? 1 : power(x, mod - 2);
}

void iinv(int &x)
{
    x = inv(x);
}

void igcd(int &g, int x)
{
    g = gcd(g, x);
}

void ans(str x)
{
    cout << x << endl;
}

void ans(const char *x)
{
    cout << x << endl;
}

template <typename T>
void ans(T x)
{
    ans(to_string(x));
}

bool isPrime(int x)
{
    int primes[168] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
    int j = 0;
    while (primes[j] < floor(sqrt(x)) + 1)
    {
        if (x % primes[j] == 0)
        {
            return false;
        }
        j++;
    }
    return true;
}

void sieve(int n = 1000005)
{
    bool p[1000005];
    memset(p, 1, sizeof(p));
    p[0] = p[1] = 0;
    for (int i = 2; i * i < n; i++)
    {
        if (p[i])
        {
            for (int j = 2 * i; j < n; j += i)
            {
                p[j] = 0;
            }
        }
    }
}

vi range(int n)
{
    vi v(n);
    for (int i = 1; i < n; i++)
    {
        v[i] = i;
    }
    rtn v;
}

int dp[201][201][40], fact[201], ifact[201];
int vis[201][201][40];
int n, a1;

int rec(int i, int sum, int k)
{
    if (i == n)
        rtn fact[n];
    if (k == 0)
        rtn mul(fact[n], ifact[n - i]);
    if (vis[i][sum][k] == a1)
        rtn dp[i][sum][k];
    vis[i][sum][k] = a1;
    int &a = dp[i][sum][k];
    a = 0;
    int r = (a1 - sum) / k;
    for (int c = r; c >= 0; c--)
    {
        if (k > 1 && i + c < n - a1 + 1 - k + 1)
            cnt;
        ;
        iadd(a, mul(rec(i + c, sum + c * k, k - 1), ifact[c]));
    }
    rtn a;
}
void pre()
{
    fact[0] = 1;
    ifact[0] = 1;
}

void solve()
{
    cin >> n >> mod;
    for (int i = 1; i <= n; i++)
    {
        fact[i] = mul(i, fact[i - 1]);
        ifact[i] = inv(fact[i]);
    }
    int a = 0;
    int lim = max(n - (sqrt(4 * n + 1) + 1) / 2, n - 2 * sqrt(n));
    for (a1 = max(1, n - lim); a1 <= n; a1++)
    {
        iadd(a, rec(0, 0, n + 1 - a1));
    }
    ans(a);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cerr.tie(NULL);
// cout << fixed;
// cout.precision(10);
// cerr << fixed;
// cerr.precision(6);
#ifndef ONLINE_JUDGE
    freopen("../../input.txt", "r", stdin);
    freopen("../../output.txt", "w", stdout);
    freopen("../../error.txt", "w", stderr);
#endif
    clock_t tStart = clock();

    pre();
    // W()
    solve();

    double t = (double)(clock() - tStart) / CLOCKS_PER_SEC;
    cerr << endl
         << "Time: " << t;
    rtn 0;
}

/*

*/