using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (k, q) = (c[0], c[1]); var list = new List{ 1 }; while (list[^1] <= 1_000_000_000_000_000_000) { list.Add(decimal.Round(list[^1] * k / (k - 1), MidpointRounding.ToPositiveInfinity)); } var ans = new decimal[q]; for (var i = 0; i < q; ++i) { var n = long.Parse(ReadLine()); var pos = LowerBound(0, n, list); ans[i] = n < list[pos] ? list[pos - 1] : list[pos]; } WriteLine(string.Join("/n", ans)); } static int LowerBound(int left, long min, List list) { if (list[left] >= min) return left; var ng = left; var ok = list.Count; while (ok - ng > 1) { var center = (ng + ok) / 2; if (list[center] < min) ng = center; else ok = center; } return ok; } }