#include using namespace std; using ll = long long; int main(){ ll K, Q; cin >> K >> Q; vector A = {0}; auto next = [&](ll x) -> ll { ll ok = x + x / (K - 1), ng = (x + 1) + (x + K) / (K - 1); auto check = [&](ll y) -> bool { return y - (y + K - 1) / K <= x; }; while(abs(ok - ng) > 1){ ll cen = (ok + ng) / 2; (check(cen) ? ok : ng) = cen; } return ok; }; while(A.back() <= (ll)1e18){ A.push_back(next(A.back())); } while(Q--){ ll N; cin >> N; cout << *--lower_bound(A.begin(), A.end(), N) + 1 << endl; } }