#include using namespace std; int main() { int K,Q; cin >> K >> Q; vectortmp1; tmp1.push_back(1); long long sum = 1; for(int i = 1; sum <= 1001001001001001001; i++) { sum += (sum+K-2)/(K-1); tmp1.push_back(sum); } while (Q--) { long long N; cin >> N; int it = upper_bound(tmp1.begin(),tmp1.end(),N)-tmp1.begin()-1; cout << tmp1[it] << endl; } }