#include using namespace std; int main(){ int K, Q; cin >> K >> Q; vector ans; ans.push_back(K); while(ans.back() <= 1000000000000000000){ long long temp = ans.back(); long long ub = 100000000000000; long long lb = -1; while(ub - lb > 1){ long long mid = (ub + lb) / 2; long long t = mid * (K - 1); if(t < temp) lb = mid; else ub = mid; } ans.push_back(ub + temp); } while(Q--){ long long 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; } } }