#include using namespace std; typedef unsigned long long ull; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); long long K, Q; cin >> K >> Q; vector ans; ans.push_back(K); while(ans.back() <= 1000000000000000000ULL){ ull temp = ans.back(); ull ub = 9000000000000000000ULL / (K - 1); ull lb = 0; while(ub - lb > 1){ ull mid = (ub + lb) / 2; ull t = mid * (K - 1); if(t < temp) lb = mid; else ub = mid; } ans.push_back(ub + temp); } while(Q--){ ull N; cin >> N; if(N <= K) cout << N << endl; else{ int ind = lower_bound(ans.begin(), ans.end(), N) - ans.begin(); cout << ans[ind - 1] << endl; } } }