#include using namespace std; using ll=long long; using ull=unsigned long long; using pii=pair; #define INF LONG_MAX #define MOD1 1000000007 #define MOD2 998244353 #define MOD MOD1 #define rng(a) a.begin(),a.end() #define rrng(a) a.end(),a.begin() #define endl "\n" #define int ll signed main(){ ios::sync_with_stdio(false); cin.tie(0); int K,Q; cin>>K>>Q; for(int i=0;i>N; vectorC; while(true){ C.push_back(N); if(N==1)break; N-=(N-1)/K+1; } reverse(rng(C)); int NN=C.size(); int now=0; for(int i=0;i1){ m=(r+l)/2; if(m*K-m<=now)l=m; else r=m; } now+=l+1; } cout<