#include using namespace std; typedef long long ll; ll k; ll solve(ll x){ if(x<=k) return x-1; ll y=solve(x-(x+k-1)/k); return y/(k-1)*k+1+y%(k-1); } int main() { int q; cin>>k>>q; while(q--){ ll n; cin>>n; printf("%lld\n", solve(n)+1); } return 0; }