import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) K,Q = MI() X = [1] while True: x = X[-1] new_x = (x*K+K-2)//(K-1) X.append(new_x) if new_x > 10**18: break len_X = len(X) for _ in range(Q): N = I() ok = 0 ng = len_X while ok+1 < ng: mid = (ok+ng)//2 if X[mid] <= N: ok = mid else: ng = mid ans = X[ok] print(ans) ''' K = 4 for i in range(2,1001): X = [j for j in range(1,i+1)] while True: len_X = len(X) new_X = [] for j in range(len_X): if j % K != 0: new_X.append(X[j]) X = new_X if len(X) == 1: break print(X[0],i) '''