Under construction

Still being built. Things may change

Guess the Formula Quiz Game

Time limit3sMemory limit1024 MB

Summary
Given f(x) mod p for x = 1 to p-1, recover the coefficients a_1 to a_(p-1) in the range 0 to p-1 of f(x) = sum of a_i * i^x mod p.
Level

Hard8 of 10

Topics
Number theory, Math, Divide and conquer
Solved
No attempts yet

Problem

Siru and Lucy, who failed their number theory exam, went deep into the mountains to learn number theory from ahgus, a master of the subject. ahgus decided to take disciples through a quiz game.

He has a prime pp that he cherishes and the following function.

f(x)=∑_i=1p−1a_iix (0≤a_i≤p−1)f(x) = \sum\_{i=1}^{p-1} a\_{i}i^{x} \, (0 \leq a\_{i} \leq p-1)

He told them the remainder of each function value f(1)f(1), f(2)f(2), ⋯\cdots, f(p−1)f(p-1) when divided by pp. He said that only the person who can guess his beloved function is qualified to become his disciple.

Help Siru and Lucy compute the function.

Input

The first line contains the prime pp. The second line contains the remainders of f(1)f(1), f(2)f(2), ⋯\cdots, f(p−1)f(p-1) when each is divided by pp, separated by spaces.

Output

Print a_1a\_1, a_2a\_2, ..., a_p−1a\_{p-1}. It can be proven that every a_ia\_i always exists uniquely and is an integer.

Constraints

p≤300,000p \leq 300,000

Examples2

  1. Example 1

    Input
    5
    0 0 4 0
    
    Expected output
    1 2 3 4
    
  2. Example 2

    Input
    7
    6 6 0 4 2 2
    
    Expected output
    1 5 0 2 5 3