def solve(n,k): res = 0 while n: res += 1 n -= (n-1)//K + 1 return res import sys input = sys.stdin.readline K,Q = map(int,input().split()) for _ in range(Q): n = int(input()) cnt = solve(n,K) ok = n ng = 0 while ok-ng>1: mid = (ok+ng)//2 if solve(mid,K)==cnt: ok = mid else: ng = mid print(ok)