#include #include #include using namespace std; int K,T; long N; vectorA; main() { cin>>K>>T; A.push_back(0); while(true) { long pre=A.back()+1; long now=pre; while(now-now/K=(long)1e18)break; } for(;T--;) { cin>>N; auto it=lower_bound(A.begin(),A.end(),N); cout<<*--it+1<