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 (n, b) = (c[0], c[1]); var a = NList; WriteLine(X(n, b, a)); } static string X(int n, int b, int[] a) { var counts = new int[n + 1]; var kinds = 0; var mul = new long[n + 1]; mul[0] = 1 % b; for (var i = 1; i < mul.Length; ++i) mul[i] = mul[i - 1] * 2 % b; var ans = new long[n]; for (var i = 0; i < n; ++i) { if (counts[a[i]] == 0) ++kinds; ++counts[a[i]]; if (counts[a[i]] > 1) { ans[i] = mul[n]; } else { ans[i] = (mul[n] - mul[n - kinds] + b) % b; } } return string.Join("\n", ans); } }