import sys def main(): input = sys.stdin.read().split() ptr = 0 K = int(input[ptr]) ptr += 1 Q = int(input[ptr]) ptr += 1 queries = [int(input[ptr + i]) for i in range(Q)] ptr += Q K_minus_1 = K - 1 for N in queries: if N == 1: print(1) continue # Collect the sequence of m's list_m = [] current_n = N while current_n > 1: m = (current_n + K - 1) // K list_m.append(m) current_n -= m # Reverse to process from the earliest step to latest list_m.reverse() x = 1 for m in list_m: if K_minus_1 == 0: # K is 1, but according to problem statement K >=2 pass # This case is impossible as per constraints else: threshold = (m - 1) * K_minus_1 if x <= threshold: q = (x - 1) // K_minus_1 x += q + 1 else: x += m print(x) if __name__ == "__main__": main()