import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,b = map(int,input().split())
a = list(map(int,input().split()))

s = set([a[0]])
ans = [pow(2, n-1, b)]
all = pow(2, n, b)

for i in range(1,n):
    if a[i] in s:
        ans.append(all)
    else:
        s.add(a[i])
        tmp = all - (pow(2, n-len(s), b))
        ans.append(tmp%b)
print(*ans, sep = "\n")