using System.Collections.Generic; using System; public class hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var t = int.Parse(line[0]); var b = int.Parse(line[1]); while (t-- > 0) { var n = int.Parse(Console.ReadLine().Trim()); var ans = new List(); while (n != 0) { var mod = n % b; n /= b; if (mod < 0) { n++; mod -= b; } ans.Add(mod); } ans.Reverse(); Console.WriteLine(string.Join("", ans)); } } }