You are given a prime number "p" and a sequence of "p" integers consisting of zeros and ones. Find a polynomial of degree at most "p-1" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and "p-1". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.

# Buggy version:
fin=open('in','r')
input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x):
	m=p-2
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i+1 for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[i]-=fact[p-1]*inv[i]*inv[p-1-i]*j**i
		else:coeff[i]+=fact[p-1]*inv[i]*inv[p-1-i]*j**i
	coeff[0]-=1
coeff=[((-t)%p+p)%p for t in coeff]
print(*coeff)

# Fixed version:
#fin=open('in','r')
#input=lambda:fin.readline().strip()

p=int(input())
fact=[0]*p
inv=[0]*p
def f(x,m=p-2):
	ans=1
	while m:
		if m&1:ans=ans*x%p
		x=x*x%p
		m>>=1
	return ans
fact[0]=inv[0]=1
for i in range(1,p):
	fact[i]=fact[i-1]*i%p
	inv[i]=inv[i-1]*f(i)%p
r=list(map(int,input().split()))
c=[i for i in range(p) if r[i] == 1]
#sum of -((x-j)^(p-1)-1)
# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))
coeff=[0]*p
for j in c:
	for i in range(p-1,-1,-1):
		if i&1:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
		else:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p
	coeff[0]+=1
coeff=[(t%p+p)%p for t in coeff]
print(*coeff)

# Buggy version:
P = int(input())
A = list(map(int, input().split()))

Q = [1 for _ in range(P)]

for i in range(P):
    if A[i]:
        for k in range(P):
            if i == k:
                continue
            Q[i] *= (i - k)
            Q[i] %= P
    else:
        Q[i] = 0

for i in range(P):
    Q[i] = pow(Q[i], P - 2, P)

F = [0 for _ in range(P + 1)]
F[0] = 1

for i in range(P):
    tmp = [0 for _ in range(P + 1)]
    for j in range(1, P + 1):
        tmp[j] += F[j - 1]
        tmp[j] %= P
    for j in range(P + 1):
        tmp[j] += F[j] * (-i)
        tmp[j] %= P
    F = tmp

res = [0 for _ in range(P)]

for i in range(P):
    G = [0 for _ in range(P)]
    G[P - 1] = F[P]
    res[P - 1] += Q[i] * G[P - 1]
    res[P - 1] %= P
    for j in range(P - 1)[::-1]:
        G[j] = F[j + 1] + i * G[j + 1]
        G[j] %= P
        res[j] += Q[i] * G[j]
        res[j] %= P

print(*res)

# Fixed version:
P = int(input())
A = list(map(int, input().split()))

Q = [1 for _ in range(P)]

for i in range(P):
    if A[i]:
        for k in range(P):
            if i == k:
                continue
            Q[i] *= (i - k)
            Q[i] %= P
        Q[i] = pow(Q[i], P - 2, P)
    else:
        Q[i] = 0

F = [0 for _ in range(P + 1)]
F[0] = 1

for i in range(P):
    tmp = [0 for _ in range(P + 1)]
    for j in range(1, P + 1):
        tmp[j] += F[j - 1]
        tmp[j] %= P
    for j in range(P + 1):
        tmp[j] += F[j] * (-i)
        tmp[j] %= P
    F = tmp

res = [0 for _ in range(P)]

for i in range(P):
    G = [0 for _ in range(P)]
    G[P - 1] = F[P]
    res[P - 1] += Q[i] * G[P - 1]
    res[P - 1] %= P
    for j in range(P - 1)[::-1]:
        G[j] = F[j + 1] + i * G[j + 1]
        G[j] %= P
        res[j] += Q[i] * G[j]
        res[j] %= P

print(*res)

# Buggy version:
p = int(input())
a = list(map(int, input().split()))

MOD = p
MAX = p + 10
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


b = [0] * p
for j in range(p):
    if a[j] == 1:
        b[0] += 1
        for k in range(p):
            b[k] += comb(p - 1, k) * pow(j, p - 1 - k, MOD)
            b[k] %= MOD

print(*b)


# Fixed version:
p = int(input())
a = list(map(int, input().split()))

MOD = p
MAX = p + 10
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


b = [0] * p
for j in range(p):
    if a[j] == 1:
        b[0] += 1
        for k in range(p):
            b[k] += comb(p - 1, k) * pow(j, p - 1 - k, MOD) * (-1)**(
                (p - k) % 2)
            b[k] %= MOD

print(*b)

# Buggy version:
p = int(input())
a = list(map(int, input().split()))

list_size = p-1

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % p)

f_r_list[-1] = pow(f_list[-1], p - 2, p)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p 

pows = [[1] for x in range(p)]
for i in range(p):
	for _ in range(p-1):
		pows[i].append((pows[i][-1] * i) % p)

ans = [0 for _ in range(p)]
for i, x in enumerate(a):
	if x == 0:
		continue
	ans[0] += 1
	ans[0] %= p
	for j in range(p):
		ans[j] -= pows[p-i][p-1-j] * comb(p-1, j)
		ans[j] %= p

print(*ans)

# Fixed version:
p = int(input())
a = list(map(int, input().split()))

list_size = p-1

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % p)

f_r_list[-1] = pow(f_list[-1], p - 2, p)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p 

pows = [[1] for x in range(p)]
for i in range(p):
	for _ in range(p-1):
		pows[i].append((pows[i][-1] * i) % p)

ans = [0 for _ in range(p)]
for i, x in enumerate(a):
	if x == 0:
		continue
	ans[0] += 1
	ans[0] %= p
	for j in range(p):
		ans[j] -= pows[(p-i)%p][p-1-j] * comb(p-1, j)
		ans[j] %= p

print(*ans)

# Buggy version:
import sys
P = int(input())
As = list(map(int, input().split()))
rs = [0]*P
mod = P
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
C = []
for i in range(P):
    C.append(cmb(P-1, i))


for i in range(P):
    if not i % 100:
        print(i)
    if As[i]:
        rs[0] += 1
        tmp = 1
        for k in range(P):
            k = P-1-k
            rs[k] += (-1 + 2*(k%2)) * tmp * C[k]
            rs[k] %= mod
            tmp = tmp * i % mod
print(*rs)


# Fixed version:
import sys
P = int(input())
As = list(map(int, input().split()))
rs = [0]*P
mod = P
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
C = []
for i in range(P):
    C.append(cmb(P-1, i))


for i in range(P):
    if As[i]:
        rs[0] += 1
        tmp = 1
        for k in range(P):
            k = P-1-k
            rs[k] += (-1 + 2*(k%2)) * tmp * C[k]
            rs[k] %= mod
            tmp = tmp * i % mod
print(*rs)

# Buggy version:
p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])

# Fixed version:
p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])

# Buggy version:
#import sys
#input = sys.stdin.readline
def getInv(N,Q):
    inv = [0] * (N + 1)
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

def getCmb(N,Q):
    inv = getInv(N,Q)
    nCr = [1] * (N + 1)
    for i in range(1, N + 1):
        nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q
    return nCr


def main():
    p = int( input())
    A = list( map( int, input().split()))
    ANS = [A[0]]
    pm1Ck = getCmb(p-1,p)
    Pow = [[0]*p for _ in range(p+1)]
    for i in range(1,p):
        Pow[i][0] = i
    for i in range(1,p):
        for k in range(p-1):
            Pow[i][k+1] = Pow[i][k]*i%p
    for k in range(1,p):
        now = 0
        for i in range(p):
            now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]
#            now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]
            now %= p
        ANS.append(now)
    print( " ".join( map( str, ANS)))
    # for i in range(p):
    #     now = 0
    #     for k in range(p):
    #         now += ANS[k]*pow(i,k,p)
    #         now %= p
    #     print(A[i], now)
if __name__ == '__main__':
    main()


# Fixed version:
#import sys
#input = sys.stdin.readline
def getInv(N,Q):
    inv = [0] * (N + 1)
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

def getCmb(N,Q):
    inv = getInv(N,Q)
    nCr = [1] * (N + 1)
    for i in range(1, N + 1):
        nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q
    return nCr


def main():
    p = int( input())
    A = list( map( int, input().split()))
    ANS = [A[0]]
    pm1Ck = getCmb(p-1,p)
    Pow = [[0]*p for _ in range(p+1)]
    for i in range(p+1):
        Pow[i][0] = 1
    for i in range(1,p):
        for k in range(p-1):
            Pow[i][k+1] = Pow[i][k]*i%p
    for k in range(1,p):
        now = 0
        for i in range(p):
            now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]
#            now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]
            now %= p
        ANS.append(now)
    print( " ".join( map( str, ANS)))
    # for i in range(p):
    #     now = 0
    #     for k in range(p):
    #         now += ANS[k]*pow(i,k,p)
    #         now %= p
    #     print(A[i], now)
if __name__ == '__main__':
    main()

# Buggy version:
p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        s = 1
        for j in range(p):
            b[j] -= comb(p - 1, j) * s
            b[j] %= MOD
            s *= -i
            s %= MOD

print(*b)

# Fixed version:
import sys
input = sys.stdin.readline
p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        s = 1
        for j in range(p - 1, -1, -1):
            b[j] -= comb(p - 1, j) * s
            b[j] %= MOD
            s *= -i
            s %= MOD

print(*b)

# Buggy version:
import sys
input = sys.stdin.readline
p=int(input())
A=[int(i) for i in input().split()]
B=[0]*p

P=[[0]*p for _ in range(p)]
for i in range(1,p): 
  for j in range(p):
    if j==0:
      P[i][j]=i
    else:
      P[i][j]=(P[i][j-1]*i)%p
PP=[0]*p
for i in range(1,p):
  for j in range(1,p):
    PP[j]=(PP[j]+P[i][j])%p
for i in range(p):
  a=A[i]
  B[0]-=a
  for j in range(1,p):
    B[j]-=a*PP[j]
    if j==p-1:
      B[j]+=a
B=B[::-1]
for i in range(p):
  B[i]%=p
print(*B)

# Fixed version:
import sys
input = sys.stdin.readline
p=int(input())
A=[int(i) for i in input().split()]
B=[0]*p

P=[[0]*p for _ in range(p)]
for i in range(1,p): 
  for j in range(1,p):
    if j==1:
      P[i][j]=i
    else:
      P[i][j]=(P[i][j-1]*i)%p

for i in range(p):
  a=A[i]
  B[0]-=a
  for j in range(1,p):
    B[j]-=a*P[i][j]
    if j==p-1:
      B[j]+=a
B=B[::-1]
for i in range(p):
  B[i]%=p
print(*B)

# Buggy version:
p = int(input())
a_list = list(map(int, input().split()))
r_list = [0] * p

fact = [0] * p
fact[0] = 1
for i in range(1, p):
    fact[i] = fact[i - 1] * i % p

fact_inv = [0] * p
fact_inv[-1] = pow(fact[-1], p-2, p)
for i in range(p-2, -1 ,-1):
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % p

ncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]

for j in range(p):
    if a_list[j] == 0:
        continue
    k = 1
    for i in range(p-1, -1, -1):
        r_list[i] -= ncr[i] * k
        r_list[i] %= p
        k *= -j
        k %= p
    r_list[0] += 1


print(*r_list)


# Fixed version:
p = int(input())
a_list = list(map(int, input().split()))
r_list = [0] * p

fact = [0] * p
fact[0] = 1
for i in range(1, p):
    fact[i] = fact[i - 1] * i % p

fact_inv = [0] * p
fact_inv[-1] = pow(fact[-1], p-2, p)
for i in range(p-2, -1 ,-1):
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % p

ncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]

for j in range(p):
    if a_list[j] == 0:
        continue
    k = 1
    for i in range(p-1, -1, -1):
        r_list[i] -= ncr[i] * k
        r_list[i] %= p
        k *= -j
        k %= p
    r_list[0] += 1

r_list[0] %= p
print(*r_list)

# Buggy version:
p = int(input())
mod = p


def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%mod
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], mod -2, mod)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % mod
    return frac, fraci

frac, fraci = frac(p)



A = list(map(int, input().split()))

C = [0]*p
for i in range(p):
    a = A[i]
    for j in range(i):
        a = (a-C[j]*frac[i]*fraci[i-j])
    C[i] = fraci[i]*a%p

B = [0]*p
t = [0]*p
t[0] = 1
for i in range(1, p):
    t2 = ([0] + t)[::-1]
    t2 = [a-b*i for a, b in zip(t2, t)]
    for j in range(p):
        B[j] += t2[j]*C[i]
    t = t2[:]

B = [b%p for b in B]
print(*B)


# Fixed version:
p = int(input())
mod = p


def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%mod
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], mod -2, mod)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % mod
    return frac, fraci

frac, fraci = frac(p)



A = list(map(int, input().split()))

C = [0]*p
for i in range(p):
    a = A[i]
    for j in range(i):
        a = (a-C[j]*frac[i]*fraci[i-j])
    C[i] = fraci[i]*a%p
B = [0]*p
t = [0]*p
t[0] = 1
for i in range(p):
    for j in range(p):
        B[j] += t[j]*C[i]
    t2 = ([0] + t)[:-1]
    t2 = [(a-b*i)%p for a, b in zip(t2, t)]
    t = t2[:]

B = [b%p for b in B]
print(*B)