import sys def main(): input = sys.stdin.read().split() ptr = 0 K = int(input[ptr]) ptr += 1 Q = int(input[ptr]) ptr += 1 for _ in range(Q): N = int(input[ptr]) ptr += 1 current_M = N current_f = 1 while current_M > 1: R = (current_M - 1) // K + 1 next_M = current_M - R x = (current_f - 1) // (K - 1) P = current_f + x + 1 current_f = P current_M = next_M print(current_f) if __name__ == '__main__': main()